cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [04/43] git commit: Fix cordova plugin add with trailing slash
Date Thu, 09 May 2013 23:00:06 GMT
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/master
Commit: 10ad93df05caeec04dc7bcdfe05dc682b75075a5
Parents: fb7cbc6
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Tue Mar 26 14:55:28 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@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);


Mime
View raw message