incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [10/78] [abbrv] git commit: reasonable timeout values for tests. callback invocation for plugin support. fixing plugin listing issue
Date Fri, 27 Jul 2012 00:29:15 GMT
reasonable timeout values for tests. callback invocation for plugin support. fixing plugin
listing issue


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/923b5410
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/923b5410
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/923b5410

Branch: refs/heads/cordova-client
Commit: 923b54104885bb165976cb9e7e88e14c38ee2402
Parents: 954e959
Author: Fil Maj <maj.fil@gmail.com>
Authored: Wed Jul 25 15:36:13 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Wed Jul 25 15:36:13 2012 -0700

----------------------------------------------------------------------
 package.json           |    7 +++--
 spec/_platform.spec.js |    6 ++--
 spec/plugin.spec.js    |   55 -------------------------------------------
 src/plugin.js          |   27 ++++++++++++++++----
 4 files changed, 28 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/923b5410/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 6b0205c..c7282ad 100644
--- a/package.json
+++ b/package.json
@@ -21,9 +21,10 @@
   ],
   "dependencies": {
     "colors":">=0.6.0",
-    "wrench":"",
-    "elementtree":"",
-    "pluginstall":"git+https://github.com/filmaj/pluginstall.git"
+    "wrench":"1.3.9",
+    "elementtree":"0.1.1",
+    "pluginstall":"git+https://github.com/filmaj/pluginstall.git",
+    "ncallbacks":"1.0.0"
   },
   "devDependencies": {
     "jasmine-node":">=1.0.0"

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/923b5410/spec/_platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/_platform.spec.js b/spec/_platform.spec.js
index 378d705..91d7f02 100644
--- a/spec/_platform.spec.js
+++ b/spec/_platform.spec.js
@@ -80,7 +80,7 @@ describe('platform command', function() {
             runs(function() {
                 cordova.platform('add', 'android', cb);
             });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
         });
     });
 
@@ -104,7 +104,7 @@ describe('platform command', function() {
             runs(function() {
                 cordova.platform('add', 'android', cb);
             });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
         });
     });
 
@@ -129,7 +129,7 @@ describe('platform command', function() {
             runs(function() {
                 cordova.platform('add', 'android', cb);
             });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
+            waitsFor(function() { return cb.wasCalled; }, "create callback", 500);
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/923b5410/spec/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/plugin.spec.js b/spec/plugin.spec.js
index 5085636..6354f5c 100644
--- a/spec/plugin.spec.js
+++ b/spec/plugin.spec.js
@@ -58,67 +58,12 @@ describe('plugin command', function() {
 
             expect(cordova.plugin('ls')).toEqual('No plugins added. Use `cordova plugin add
<plugin>`.');
         });
-
-        it('should list out added plugins in a project', function() {
-            var cb = jasmine.createSpy().andCallFake(function() {
-                expect(cordova.plugin('ls')).toEqual('android');
-            });
-
-            process.chdir(tempDir);
-            runs(function() {
-                cordova.plugin('add', '', cb);
-            });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
-        });
     });
 
     describe('add', function() {
-        var cwd = process.cwd();
-
-        beforeEach(function() {
-            cordova.create(tempDir);
-        });
-
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-
-        it('should add a supported platform', function() {
-            var cb = jasmine.createSpy().andCallFake(function() {
-                expect(cordova.platform('ls')).toEqual('android');
-            });
-
-            process.chdir(tempDir);
-            runs(function() {
-                cordova.platform('add', 'android', cb);
-            });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
-        });
     });
 
     describe('remove', function() {
-        var cwd = process.cwd();
-
-        beforeEach(function() {
-            cordova.create(tempDir);
-        });
-
-        afterEach(function() {
-            process.chdir(cwd);
-        });
-
-        it('should remove a supported and added platform', function() {
-            var cb = jasmine.createSpy().andCallFake(function() {
-                cordova.platform('remove', 'android');
-                expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova
platform add <platform>`.');
-            });
-
-            process.chdir(tempDir);
-            runs(function() {
-                cordova.platform('add', 'android', cb);
-            });
-            waitsFor(function() { return cb.wasCalled; }, "create callback", 17500);
-        });
     });
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/923b5410/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 8f54bff..afba9f5 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -4,6 +4,7 @@ var cordova_util = require('./util'),
     cpr = wrench.copyDirSyncRecursive,
     fs = require('fs'),
     path = require('path'),
+    nCalls = require('ncallbacks'),
     config_parser = require('./config_parser'),
     exec = require('child_process').exec,
     ls = fs.readdirSync;
@@ -23,10 +24,13 @@ module.exports = function plugin(command, target, callback) {
     var platforms = cfg.ls_platforms();
 
     // Massage plugin name / path
-    var pluginPath = path.join(projectRoot, 'plugins');
-    var plugins = ls(pluginPath);
-    var targetName = target.substr(target.lastIndexOf('/') + 1);
-    if (targetName[targetName.length-1] == '/') targetName = targetName.substr(0, targetName.length-1);
+    var pluginPath, plugins, targetName;
+    pluginPath = path.join(projectRoot, 'plugins');
+    plugins = ls(pluginPath);
+    if (target) { 
+        targetName = target.substr(target.lastIndexOf('/') + 1);
+        if (targetName[targetName.length-1] == '/') targetName = targetName.substr(0, targetName.length-1);
+    }
 
     switch(command) {
         case 'ls':
@@ -47,14 +51,24 @@ module.exports = function plugin(command, target, callback) {
                 throw 'Plugin "' + targetName + '" does not have a plugin.xml in the root.
Plugin must support the Cordova Plugin Specification: https://github.com/alunny/cordova-plugin-spec';
             }
 
+            var pluginWww = path.join(target, 'www');
+            var wwwContents = ls(pluginWww);
+
+            var n = wwwContents.length + platforms.length;
+            var end = nCalls(n, callback || function(){});
+
             // Iterate over all platforms in the project and install the
             // plugin.
             var cli = path.join(__dirname, '..', 'node_modules', 'pluginstall', 'cli.js');
             platforms.forEach(function(platform) {
                 var cmd = util.format('%s %s "%s" "%s"', cli, platform, path.join(projectRoot,
'platforms', platform), target);
+                console.log('executing ' + cmd);
                 exec(cmd, function(err, stderr, stdout) {
+                    end();
                     if (err) {
                         console.error(stderr);
+                        // TODO: remove plugin. requires pluginstall to
+                        // support removal.
                         throw 'An error occured during plugin installation. ' + err;
                     }
                 });
@@ -63,8 +77,6 @@ module.exports = function plugin(command, target, callback) {
             // Add the plugin web assets to the www folder as well
             // TODO: assumption that web assets go under www folder
             // inside plugin dir; instead should read plugin.xml
-            var pluginWww = path.join(target, 'www');
-            var wwwContents = ls(pluginWww);
             wwwContents.forEach(function(asset) {
                 asset = path.resolve(path.join(pluginWww, asset));
                 var info = fs.lstatSync(asset);
@@ -75,10 +87,13 @@ module.exports = function plugin(command, target, callback) {
                 } else {
                     fs.writeFileSync(wwwPath, fs.readFileSync(asset));
                 }
+                end();
             });
 
             break;
         case 'remove':
+            // TODO: remove plugin. requires pluginstall to
+            // support removal.
             throw 'Plugin removal not supported yet! sadface';
         default:
             throw 'Unrecognized command "' + command + '". Use either `add`, `remove`, or
`ls`.';


Mime
View raw message