Github user TimBarham commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/304#discussion_r39388053
--- Diff: cordova-lib/src/cordova/plugin.js ---
@@ -283,6 +283,31 @@ module.exports = function plugin(command, targets,
opts) {
}
};
+/**
+ * Calls `platformApi.prepare` for each platform in project
+ *
+ * @param {string[]} platformList List of platforms, added to current
project
+ * @param {string} projectRoot Project root directory
+ *
+ * @return {Promise}
+ */
+function preparePlatforms (platformList, projectRoot) {
+ return Q.all(platformList.map(function(platform) {
+ // TODO: this need to be replaced by real projectInfo
+ // instance for current project.
+ var project = {
+ root: projectRoot,
+ projectConfig: new
ConfigParser(cordova_util.projectConfig(projectRoot)),
+ locations: {
+ plugins: path.join(projectRoot, 'plugins'),
+ www: cordova_util.projectWww(projectRoot)
+ }
+ };
+
+ return platforms.getPlatformApi(platform).prepare(project);
+ }));
+}
+
--- End diff --
Logic looks good to me. Just one suggestion - the guts of
`preparePlatforms()` is an exact duplicate of code within `prepare.js`,
correct? Why not add a `preparePlatform()` method in `prepare.js`, and call
that from within the loop here and within the loop in `prepare`?
I guess one argument against that would be that this logic will become
pretty simplistic once there is a real `projectInfo` instance for the project,
but on the other hand, sharing this code means you don't have to update that in
two places. So... I guess up to you :smile:.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]