You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/03/25 22:34:13 UTC
[2/2] git commit: Make cordova plugin add rely on plugman
Make cordova plugin add rely on plugman
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/76ed29cc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/76ed29cc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/76ed29cc
Branch: refs/heads/future
Commit: 76ed29cc330d2fe79bd092c106b0ab6b31cdc626
Parents: bdd9210
Author: Braden Shepherdson <br...@gmail.com>
Authored: Mon Mar 25 17:33:45 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Mon Mar 25 17:33:45 2013 -0400
----------------------------------------------------------------------
src/plugin.js | 44 ++++----------------------------------------
src/prepare.js | 1 -
2 files changed, 4 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/76ed29cc/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 93e90d8..b323429 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -70,52 +70,16 @@ module.exports = function plugin(command, targets, callback) {
} else return 'No plugins added. Use `cordova plugin add <plugin>`.';
break;
case 'add':
- if (platforms.length === 0) {
- throw new Error('You need at least one platform added to your app. Use `cordova platform add <platform>`.');
- }
targets.forEach(function(target, index) {
- var pluginContents = ls(target);
- var targetName = names[index];
- // Check if we already have the plugin.
- // TODO edge case: if a new platform is added, then you want
- // to re-add the plugin to the new platform.
- if (plugins.indexOf(targetName) > -1) {
- throw new Error('Plugin "' + targetName + '" already added to project.');
- }
- // Check if the plugin has a plugin.xml in the root of the
- // specified dir.
- if (pluginContents.indexOf('plugin.xml') == -1) {
- throw new Error('Plugin "' + targetName + '" does not have a plugin.xml in the root. Plugin must support the Cordova Plugin Specification: https://github.com/alunny/cordova-plugin-spec');
- }
-
- // Check if there is at least one match between plugin
- // supported platforms and app platforms
- var pluginXml = new plugin_parser(path.join(target, 'plugin.xml'));
- var intersection = pluginXml.platforms.filter(function(e) {
- if (platforms.indexOf(e) == -1) return false;
- else return true;
- });
- if (intersection.length === 0) {
- throw new Error('Plugin "' + targetName + '" does not support any of your application\'s platforms. Plugin platforms: ' + pluginXml.platforms.join(', ') + '; your application\'s platforms: ' + platforms.join(', '));
- }
-
hooks.fire('before_plugin_add');
-
var cli = path.join(__dirname, '..', 'node_modules', 'plugman', 'plugman.js');
-
- // Iterate over all matchin app-plugin platforms in the project and install the
- // plugin.
- intersection.forEach(function(platform) {
- var cmd = util.format('%s --platform %s --project "%s" --plugin "%s"', cli, platform, path.join(projectRoot, 'platforms', platform), target);
+ // Iterate over all platforms in the project and install the plugin.
+ platforms.forEach(function(platform) {
+ var cmd = util.format('%s --platform %s --project "%s" --plugin "%s" --plugins_dir "%s"', cli, platform, path.join(projectRoot, 'platforms', platform), target, path.join(projectRoot, 'plugins'));
var plugin_cli = shell.exec(cmd, {silent:true});
- if (plugin_cli.code > 0) throw new Error('An error occured during plugin installation for ' + platform + '. ' + plugin_cli.output);
+ if (plugin_cli.code > 0) throw new Error('An error occured during plugin installation for ' + platform + ': ' + plugin_cli.output);
});
- // Finally copy the plugin into the project
- var targetPath = path.join(pluginPath, targetName);
- shell.mkdir('-p', targetPath);
- shell.cp('-r', path.join(target, '*'), targetPath);
-
hooks.fire('after_plugin_add');
});
if (callback) callback();
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/76ed29cc/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 0d47acd..f5164eb 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -78,7 +78,6 @@ module.exports = function prepare(platforms, callback) {
parser.update_project(cfg, function() {
// Call plugman --prepare for each platform.
var cmd = util.format('%s --prepare --platform "%s" --project "%s" --www "%s" --plugins_dir "%s"', cli, platform, platformPath, parser.www_dir(), path.join(projectRoot, 'plugins'));
- console.log(cmd);
var plugman_call = shell.exec(cmd, {silent:true});
if (plugman_call.code > 0) throw new Error('An error occurred during plugman --prepare for ' + platform + ': ' + plugman_call.output);