cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject git commit: Add --link option to --fetch; make --remove handle symlinks
Date Mon, 15 Apr 2013 19:29:44 GMT
Updated Branches:
  refs/heads/future 73047c40a -> 26017e8c3


Add --link option to --fetch; make --remove handle symlinks

--fetch --link symlinks a plugin found in a local directory into the
plugins directory instead of copying. It fails with an appropriate error
message for Git URLs.

--remove used to delete the contents of the linked directory, which is
terrible. Now it detects that the dir is a symlink and just unlinks it.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/26017e8c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/26017e8c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/26017e8c

Branch: refs/heads/future
Commit: 26017e8c3ea8e498e87d31f25bb87e3bfb64878a
Parents: 73047c4
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Mon Apr 15 15:25:48 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Mon Apr 15 15:25:48 2013 -0400

----------------------------------------------------------------------
 plugman.js      |   21 ++++++++++++++++++---
 util/plugins.js |    2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/26017e8c/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index eea2549..701660d 100755
--- a/plugman.js
+++ b/plugman.js
@@ -47,6 +47,7 @@ var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry' ]
             , 'prepare' : Boolean
             , 'plugins': path
             , 'www': path
+            , 'link': Boolean
             , 'variable' : Array
             }, shortHands = { 'var' : 'variable' };
 
@@ -113,7 +114,7 @@ function printUsage() {
     console.log('Usage\n---------');
     console.log('Fetch a plugin:\n\t' + package.name + ' --fetch --plugin <directory|git-url|name>
[--plugins_dir <directory>]\n');
     console.log('Install an already fetched plugin:\n\t' + package.name + ' --platform <'+
platforms +'> --project <directory> --plugin <name> [--plugins_dir <directory>]\n');
-    console.log('Uninstall a plugin:\n\t' + package.name + ' --remove --platform <'+ platforms
+'> --project <directory> --plugin <name> [--plugins_dir <directory>]\n');
+    console.log('Uninstall a plugin:\n\t' + package.name + ' --uninstall --platform <'+
platforms +'> --project <directory> --plugin <name> [--plugins_dir <directory>]\n');
     console.log('Delete the local copy of a plugin:\n\t' + package.name + ' --remove --plugin
<name> [--plugins_dir <directory>]\n');
     console.log('List plugins:\n\t' + package.name + ' --list [--plugins_dir <directory>]\n');
     console.log('Prepare project:\n\t' + package.name + ' --prepare --platform <ios|android|bb10>
--project <directory> --www <directory> [--plugins_dir <directory>]');
@@ -169,6 +170,9 @@ function fetchPlugin(plugin_dir) {
 
     // clone from git repository
     if(plugin_dir.indexOf('https://') == 0 || plugin_dir.indexOf('git://') == 0) {
+        if (cli_opts.link) {
+            throw new Error('--link is not supported for git URLs');
+        }
         plugin_dir = plugins.clonePluginGitRepo(plugin_dir, plugins_dir);
     } else { // Copy from the local filesystem.
         var lastSlash = plugin_dir.lastIndexOf(path.sep);
@@ -179,14 +183,25 @@ function fetchPlugin(plugin_dir) {
         dest = path.join(plugins_dir, dest);
 
         shell.rm('-rf', dest);
-        shell.cp('-R', plugin_dir, plugins_dir); // Yes, not dest.
+        if (cli_opts.link) {
+            fs.symlinkSync(path.resolve(plugin_dir), dest, 'dir');
+        } else {
+            shell.cp('-R', plugin_dir, plugins_dir); // Yes, not dest.
+        }
 
         plugin_dir = dest;
     }
 }
 
 function removePlugin(name) {
-    shell.rm('-rf', path.join(plugins_dir, cli_opts.plugin));
+    var target = path.join(plugins_dir, cli_opts.plugin);
+    var stat = fs.lstatSync(target);
+
+    if (stat.isSymbolicLink()) {
+        fs.unlinkSync(target);
+    } else {
+        shell.rm('-rf', target);
+    }
     console.log('Plugin ' + cli_opts.plugin + ' deleted.');
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/26017e8c/util/plugins.js
----------------------------------------------------------------------
diff --git a/util/plugins.js b/util/plugins.js
index 333fd92..7dacf9e 100644
--- a/util/plugins.js
+++ b/util/plugins.js
@@ -39,7 +39,7 @@ exports.getPluginInfo = function(plugin_name, success, error) {
             plugin_info = response.rows[0].value;
             success(plugin_info);
           } else {
-            error("Could not find information on "+plugin_dir+" plugin");
+            error("Could not find information on "+plugin_name+" plugin");
           }
       });
       


Mime
View raw message