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/26 19:55:48 UTC
git commit: Fix cordova plugin add with trailing slash
Updated Branches:
refs/heads/future fb7cbc60f -> 10ad93df0
Fix cordova plugin add with trailing slash
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/10ad93df
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/10ad93df
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/10ad93df
Branch: refs/heads/future
Commit: 10ad93df05caeec04dc7bcdfe05dc682b75075a5
Parents: fb7cbc6
Author: Braden Shepherdson <br...@gmail.com>
Authored: Tue Mar 26 14:55:28 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Tue Mar 26 14:55:28 2013 -0400
----------------------------------------------------------------------
src/plugin.js | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/10ad93df/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 03442eb..f2638f5 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -50,11 +50,14 @@ module.exports = function plugin(command, targets, callback) {
var pluginPath, plugins, names = [];
pluginPath = path.join(projectRoot, 'plugins');
plugins = ls(pluginPath);
- if (targets) {
+ if (targets) {
if (!(targets instanceof Array)) targets = [targets];
targets.forEach(function(target) {
- var targetName = target.substr(target.lastIndexOf('/') + 1);
- if (targetName[targetName.length-1] == '/') targetName = targetName.substr(0, targetName.length-1);
+ if (target[target.length - 1] == path.sep) {
+ target = target.substring(0, target.length - 1);
+ }
+
+ var targetName = target.substr(target.lastIndexOf(path.sep) + 1);
names.push(targetName);
});
}
@@ -75,7 +78,9 @@ module.exports = function plugin(command, targets, callback) {
var cli = path.join(__dirname, '..', 'node_modules', 'plugman', 'plugman.js');
var pluginsDir = path.join(projectRoot, 'plugins');
- var lastSlash = target.lastIndexOf('/', target.length - 2);
+ if (target[target.length - 1] == path.sep) {
+ target = target.substring(0, target.length - 1);
+ }
// Fetch the plugin first.
var cmd = util.format('%s --fetch --plugin "%s" --plugins_dir "%s"', cli, target, pluginsDir);