You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2015/03/07 05:41:10 UTC

cordova-lib git commit: Bugfix to json.parse before using cfg

Repository: cordova-lib
Updated Branches:
  refs/heads/copy-from-app-hello-world 9ce5bc1ba -> 2d9f7a713


Bugfix to json.parse before using cfg


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

Branch: refs/heads/copy-from-app-hello-world
Commit: 2d9f7a7132ff74e120dcd3f642dbf15ac744f580
Parents: 9ce5bc1
Author: Michal Mocny <mm...@gmail.com>
Authored: Fri Mar 6 23:40:49 2015 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Fri Mar 6 23:40:49 2015 -0500

----------------------------------------------------------------------
 cordova-lib/src/cordova/create.js | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/2d9f7a71/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index ac67a86..c0f0a3a 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -54,11 +54,12 @@ function create(dir, optionalId, optionalName, cfg) {
         if (!dir) {
             throw new CordovaError('At least the dir must be provided to create new project. See `' + cordova_util.binname + ' help`.');
         }
+
+        cfg = cfg || config.read(dir);
         if (!cfg) {
-            cfg = config.read(dir);
-            if (!cfg) {
-                throw new CordovaError('Must provide a project configuration.');
-            }
+            throw new CordovaError('Must provide a project configuration.');
+        } else if (typeof cfg == 'string') {
+            cfg = JSON.parse(cfg);
         }
 
         if (optionalId) cfg.id = optionalId;
@@ -84,11 +85,6 @@ function create(dir, optionalId, optionalName, cfg) {
             throw new CordovaError('Path already exists and is not empty: ' + dir);
         }
 
-        // Massage parameters
-        if (typeof cfg == 'string') {
-            cfg = JSON.parse(cfg);
-        }
-
         if (cfg.id && !validateIdentifier(cfg.id)) {
             throw new CordovaError('App id contains a reserved word, or is not a valid identifier.');
         }


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