cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [5/6] git commit: Work for [CB-4077]: uninstallation should look at platform json file for determining which plugins to iterate over. fetching multiple plugins from git should not collide in temp dir.
Date Wed, 10 Jul 2013 18:03:25 GMT
Work for [CB-4077]: uninstallation should look at platform json file for determining which
plugins to iterate over. fetching multiple plugins from git should not collide in temp dir.


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

Branch: refs/heads/master
Commit: 611ec4db2dbe2a2918a1416e2cfd2787fa4335ee
Parents: 859e275
Author: Fil Maj <maj.fil@gmail.com>
Authored: Tue Jul 9 14:10:48 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Jul 10 11:01:28 2013 -0700

----------------------------------------------------------------------
 spec/prepare.spec.js | 7 +++----
 src/install.js       | 6 ++----
 src/prepare.js       | 8 +++-----
 src/util/plugins.js  | 6 +++---
 4 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/611ec4db/spec/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/prepare.spec.js b/spec/prepare.spec.js
index 675444a..5bf51ff 100644
--- a/spec/prepare.spec.js
+++ b/spec/prepare.spec.js
@@ -15,12 +15,12 @@ var json = path.join(temp, 'assets', 'www', 'cordova_plugins.json');
 var js = path.join(temp, 'assets', 'www', 'cordova_plugins.js');
 
 describe('prepare', function() {
-    var proc, readdir, write, stat, read, parseET, mkdir;
+    var proc, platform_json, write, stat, read, parseET, mkdir;
     var root, findall, find;
     beforeEach(function() {
         mkdir = spyOn(shell, 'mkdir');
         proc = spyOn(config_changes, 'process');
-        readdir = spyOn(fs, 'readdirSync').andReturn([]);
+        platform_json = spyOn(config_changes, 'get_platform_json').andReturn({installed_plugins:{},dependent_plugins:{}});
         write = spyOn(fs, 'writeFileSync');
         stat = spyOn(fs, 'statSync').andReturn({isDirectory:function() { return true; }});
         root = jasmine.createSpy('ElementTree getroot').andReturn({
@@ -46,11 +46,10 @@ describe('prepare', function() {
     });
     describe('handling of js-modules', function() {
         var read, child_one;
-        var fake_plugins = ['plugin_one', 'plugin_two'];
         beforeEach(function() {
             child_one = jasmine.createSpy('getchildren').andReturn([]);
             read = spyOn(fs, 'readFileSync').andReturn('JAVASCRIPT!');
-            readdir.andReturn(fake_plugins);
+            platform_json.andReturn({installed_plugins:{plugin_one:'',plugin_two:''},dependent_plugins:{}});
             findall.andReturn([
                 {attrib:{src:'somedir', name:'NAME'}, getchildren:child_one},
                 {attrib:{src:'someotherdir', name:'NAME'}, getchildren:child_one}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/611ec4db/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 2c2c025..3868ccf 100644
--- a/src/install.js
+++ b/src/install.js
@@ -184,14 +184,12 @@ function runInstall(actions, platform, project_dir, plugin_dir, plugins_dir,
opt
                     var result = shell.exec('git rev-parse --show-toplevel', { silent:true,
async:false});
                     if (result.code === 128) {
                         var err = new Error('Error: Plugin ' + plugin_id + ' is not in git
repository. All plugins must be in a git repository.');
-                        if (callback) callback(err);
+                        if (callback) return callback(err);
                         else throw err;
-                        return;
                     } else if(result.code > 0) {
                         var err = new Error('Error trying to locate git repository for plugin.');
-                        if (callback) callback(err);
+                        if (callback) return callback(err);
                         else throw err;
-                        return;
                     }
 
                     var dep_url = path.join(result.output.trim(), dep_subdir);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/611ec4db/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 4904975..f898b84 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -46,14 +46,12 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir)
{
     config_changes.process(plugins_dir, project_dir, platform);
 
     var wwwDir = platform_modules[platform].www_dir(project_dir);
-    // TODO: perhaps this should look at platform json files to determine which plugins to
prepare?
-    var plugins = fs.readdirSync(plugins_dir).filter(function(p) {
-        return p != '.svn' && p != 'CVS';
-    });
+    var platform_json = config_changes.get_platform_json(plugins_dir, platform);
+    var plugins = Object.keys(platform_json.installed_plugins).concat(Object.keys(platform_json.dependent_plugins));
 
     // This array holds all the metadata for each module and ends up in cordova_plugins.json
     var moduleObjects = [];
-    require('../plugman').emit('log', 'Iterating over installed plugins...');
+    require('../plugman').emit('log', 'Iterating over installed plugins:', plugins);
 
     plugins && plugins.forEach(function(plugin) {
         var pluginDir = path.join(plugins_dir, plugin);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/611ec4db/src/util/plugins.js
----------------------------------------------------------------------
diff --git a/src/util/plugins.js b/src/util/plugins.js
index 90b24f7..7153926 100644
--- a/src/util/plugins.js
+++ b/src/util/plugins.js
@@ -23,8 +23,7 @@ var http = require('http'),
     fs = require('fs'),
     util = require('util'),
     shell = require('shelljs'),
-    xml_helpers = require('./xml-helpers'),
-    tmp_dir = path.join(os.tmpdir(), 'plugman-tmp');
+    xml_helpers = require('./xml-helpers');
 
 module.exports = {
     searchAndReplace:require('./search-and-replace'),
@@ -35,6 +34,7 @@ module.exports = {
             if (callback) return callback(err);
             else throw err;
         }
+        var tmp_dir = path.join(os.tmpdir(), 'plugman-tmp' +(new Date).valueOf());
 
         shell.rm('-rf', tmp_dir);
 
@@ -69,8 +69,8 @@ module.exports = {
 
                 // TODO: what if a plugin dependended on different subdirectories of the
same plugin? this would fail.
                 // should probably copy over entire plugin git repo contents into plugins_dir
and handle subdir seperately during install.
-                require('../../plugman').emit('log', 'Copying fetched plugin over "' + plugin_dir
+ '"...');
                 var plugin_dir = path.join(plugins_dir, plugin_id);
+                require('../../plugman').emit('log', 'Copying fetched plugin over "' + plugin_dir
+ '"...');
                 shell.cp('-R', path.join(tmp_dir, '*'), plugin_dir);
 
                 require('../../plugman').emit('log', 'Plugin "' + plugin_id + '" fetched.');


Mime
View raw message