cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cordova-lib git commit: made a few updates based on comments
Date Fri, 13 Feb 2015 00:53:29 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/CB-8416 0d0279c84 -> e539aa5da


made a few updates based on comments


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

Branch: refs/heads/CB-8416
Commit: e539aa5dace0b370812ced54e52ebaf381ad0fd5
Parents: 0d0279c
Author: Steve Gill <stevengill97@gmail.com>
Authored: Thu Feb 12 16:53:21 2015 -0800
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Thu Feb 12 16:53:21 2015 -0800

----------------------------------------------------------------------
 cordova-lib/src/PluginInfo.js                |  6 +--
 cordova-lib/src/plugman/createpackagejson.js |  4 +-
 cordova-lib/src/plugman/init-defaults.js     | 47 ++++++++++++-----------
 cordova-lib/src/plugman/plugman.js           |  2 +-
 cordova-lib/src/plugman/registry/registry.js | 10 ++++-
 5 files changed, 38 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e539aa5d/cordova-lib/src/PluginInfo.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/PluginInfo.js b/cordova-lib/src/PluginInfo.js
index e0690e8..accf59b 100644
--- a/cordova-lib/src/PluginInfo.js
+++ b/cordova-lib/src/PluginInfo.js
@@ -314,10 +314,10 @@ function PluginInfo(dirname) {
 // Helper function used to prefix every element of an array with cordova-
 // Useful when we want to modify platforms to be cordova-platform
 function addCordova(someArray) {
-    someArray.forEach(function(element, index, array) {
-        array[index] = 'cordova-' + element;
+    var newArray = someArray.map(function(element) {
+        return 'cordova-' + element;
     });
-    return someArray;
+    return newArray;
 }
 
 // Helper function used by most of the getSomething methods of PluginInfo.

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e539aa5d/cordova-lib/src/plugman/createpackagejson.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/createpackagejson.js b/cordova-lib/src/plugman/createpackagejson.js
index fc6eeec..0058abd 100644
--- a/cordova-lib/src/plugman/createpackagejson.js
+++ b/cordova-lib/src/plugman/createpackagejson.js
@@ -25,9 +25,7 @@ var Q = require('q'),
     init = require('init-package-json');
 
 //returns a promise
-function createPackageJson(args) {
-    var plugin_path = args[0];
-
+function createPackageJson(plugin_path) {
     var pluginInfo = new PluginInfo(plugin_path);
    
     var defaults = {

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e539aa5d/cordova-lib/src/plugman/init-defaults.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/init-defaults.js b/cordova-lib/src/plugman/init-defaults.js
index 9948a7f..5e03349 100644
--- a/cordova-lib/src/plugman/init-defaults.js
+++ b/cordova-lib/src/plugman/init-defaults.js
@@ -4,36 +4,39 @@
 /* global basename */
 /* global yes */
 /* global prompt */
+// PromZard file that is used by createpackagejson and init-package-json module
 
 var fs = require('fs'),
     path = require('path'),
     defaults = require('./defaults.json');
 
 
-function readDeps (test) { return function (cb) {
-    fs.readdir('node_modules', function (er, dir) {
-        if (er) return cb();
-        var deps = {};
-        var n = dir.length;
-        if (n === 0) return cb(null, deps);
-        dir.forEach(function (d) {
-            if (d.match(/^\./)) return next();
-
-            var dp = path.join(dirname, 'node_modules', d, 'package.json');
-            fs.readFile(dp, 'utf8', function (er, p) {
-                if (er) return next();
-                try { p = JSON.parse(p); }
-                catch (e) { return next(); }
-                if (!p.version) return next();
-                deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix')
+ p.version;
-                return next();
+function readDeps (test) { 
+    return function (cb) {
+        fs.readdir('node_modules', function (er, dir) {
+            if (er) return cb();
+            var deps = {};
+            var n = dir.length;
+            if (n === 0) return cb(null, deps);
+            dir.forEach(function (d) {
+                if (d.match(/^\./)) return next();
+
+                var dp = path.join(dirname, 'node_modules', d, 'package.json');
+                fs.readFile(dp, 'utf8', function (er, p) {
+                    if (er) return next();
+                    try { p = JSON.parse(p); }
+                    catch (e) { return next(); }
+                    if (!p.version) return next();
+                    deps[d] = config.get('save-exact') ? p.version : config.get('save-prefix')
+ p.version;
+                    return next();
+                });
             });
+            function next () {
+                if (--n === 0) return cb(null, deps);
+            }
         });
-        function next () {
-            if (--n === 0) return cb(null, deps);
-        }
-    });
-};}
+    };
+}
 
 var name = package.name || basename;
 exports.name = yes ? name : prompt('name', name);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e539aa5d/cordova-lib/src/plugman/plugman.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/plugman.js b/cordova-lib/src/plugman/plugman.js
index 73eb8bf..97d4d0d 100644
--- a/cordova-lib/src/plugman/plugman.js
+++ b/cordova-lib/src/plugman/plugman.js
@@ -219,7 +219,7 @@ plugman.commands =  {
         plugman.platform( { operation: operation, platform_name: cli_opts.platform_name }
);
     },
     'createpackagejson'  : function(cli_opts) {
-        var plugin_path = cli_opts.argv.remain;
+        var plugin_path = cli_opts.argv.remain[0];
         if(!plugin_path) {
             return console.log(plugman.help());
         }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/e539aa5d/cordova-lib/src/plugman/registry/registry.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/registry.js b/cordova-lib/src/plugman/registry/registry.js
index 4e5e8c6..680027d 100644
--- a/cordova-lib/src/plugman/registry/registry.js
+++ b/cordova-lib/src/plugman/registry/registry.js
@@ -89,8 +89,14 @@ module.exports = {
         .then(function(settings) {
             if(fs.existsSync(path.join(dir,'package.json'))) {
                 events.emit('verbose', 'temporarily moving existing package.json so we can
create one to publish to the cordova plugins registry');
-                //rename package.json to pacakge.json1 temporarily 
-                fs.renameSync(path.join(dir,'package.json'),path.join(dir,'package.json1'));

+                if(fs.existsSync(path.join(dir,'package.json1'))) {
+                    //package.json1 already exists, maybe due to an past failed attempt to
publish
+                    //we will assume that the rename has already happened.
+                    events.emit('verbose', 'package.json1 already exists. Will use');
+                } else {
+                    //rename package.json to pacakge.json1 temporarily 
+                    fs.renameSync(path.join(dir,'package.json'),path.join(dir,'package.json1'));

+                }
             }
             return manifest.generatePackageJsonFromPluginXml(dir)
             .then(function() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message