cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/4] git commit: re-adding installation by name from remote source
Date Mon, 29 Apr 2013 06:42:48 GMT
re-adding installation by name from remote source


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

Branch: refs/heads/master
Commit: 85a78f6ac9ff0e06a2e013916a4b157095ee7677
Parents: dc6a917
Author: Anis Kadri <anis@apache.org>
Authored: Sun Apr 28 14:09:49 2013 -0700
Committer: Anis Kadri <anis@apache.org>
Committed: Sun Apr 28 14:09:49 2013 -0700

----------------------------------------------------------------------
 spec/fetch.spec.js |   16 +++++++++++++++-
 src/fetch.js       |   12 ++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/85a78f6a/spec/fetch.spec.js
----------------------------------------------------------------------
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
index a3d8889..c61fbf4 100644
--- a/spec/fetch.spec.js
+++ b/spec/fetch.spec.js
@@ -33,10 +33,24 @@ describe('fetch', function() {
             fetch("https://github.com/bobeast/GAPlugin.git", temp, false);
             expect(s).toHaveBeenCalled();
         });
-        it('should throw if used with `link` param', function() {
+        it('should throw if used with url and `link` param', function() {
             expect(function() {
                 fetch("https://github.com/bobeast/GAPlugin.git", temp, true);
             }).toThrow();
         });
+        it('should call getPluginInfo and clonePluginRepo for names', function() {
+            var s1 = spyOn(plugins, 'getPluginInfo').andCallFake(function(plugin_name, callback)
{
+                callback(null, {url:"https://github.com/imhotep/ChildBrowser.git"});
+            });
+            var s2 = spyOn(plugins, 'clonePluginGitRepo');
+            fetch("ChildBrowser", temp, false, null);
+            expect(s1).toHaveBeenCalled();
+            expect(s2).toHaveBeenCalledWith('https://github.com/imhotep/ChildBrowser.git',
temp, null);
+        });
+        it('should throw if used with name and `link` param', function() {
+            expect(function() {
+                fetch('ChildBrowser', temp, true);
+            }).toThrow();
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/85a78f6a/src/fetch.js
----------------------------------------------------------------------
diff --git a/src/fetch.js b/src/fetch.js
index f01c3e2..129461d 100644
--- a/src/fetch.js
+++ b/src/fetch.js
@@ -16,11 +16,19 @@ module.exports = function fetchPlugin(plugin_dir, plugins_dir, link, callback)
{
         } else {
             plugins.clonePluginGitRepo(plugin_dir, plugins_dir, callback);
         }
+    } else if(!fs.existsSync(plugin_dir)) {
+        if (link) {
+            var err = new Error('--link is not supported for name installations');
+            if (callback) callback(err);
+            else throw err;
+        } else {
+            plugins.getPluginInfo(plugin_dir, function(err, plugin_info) {
+                plugins.clonePluginGitRepo(plugin_info.url, plugins_dir, callback);
+            });
+        }
     } else {
         // Copy from the local filesystem.
         var dest = path.join(plugins_dir, path.basename(plugin_dir));
-        // TODO: throw if local cant be resolved
-        // TODO: if local cant be resolved, query remote service.
 
         shell.rm('-rf', dest);
         if (link) {


Mime
View raw message