cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [47/50] [abbrv] cordova-lib git commit: CB-12021 : updated final changes and fixed typos/whitespace after final review
Date Thu, 09 Mar 2017 20:39:50 GMT
CB-12021 : updated final changes and fixed typos/whitespace  after final review

 This closes #518


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

Branch: refs/heads/common-2.0.x
Commit: b0402b9e51bf2d97488fedd39d13348b29f81c3c
Parents: f8b4483
Author: Audrey So <audreyso@apache.org>
Authored: Fri Feb 17 16:58:07 2017 -0800
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Tue Feb 21 15:59:57 2017 -0800

----------------------------------------------------------------------
 cordova-lib/package.json                        |  2 +-
 .../spec-cordova/pkgJson-restore.spec.js        | 33 ++++++++++----------
 cordova-lib/spec-cordova/platform.spec.js       |  3 +-
 cordova-lib/src/cordova/platform.js             |  3 --
 cordova-lib/src/cordova/plugin.js               | 17 ++++++++--
 cordova-lib/src/plugman/fetch.js                |  4 +--
 6 files changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/package.json b/cordova-lib/package.json
index d0195ca..a05d0a4 100644
--- a/cordova-lib/package.json
+++ b/cordova-lib/package.json
@@ -55,7 +55,7 @@
     "test": "npm run jshint && npm run jasmine",
     "test-ios": "npm run test && npm run jasmine-ios",
     "ci": "npm run jshint && npm run cover && codecov",
-    "jshint": "./node_modules/.bin/jshint src spec-cordova spec-plugman",
+    "jshint": "jshint src spec-cordova spec-plugman",
     "jasmine": "jasmine --captureExceptions --color",
     "jasmine-ios": "jasmine --captureExceptions --color spec-cordova/platform.spec.ios.js
--matchall",
     "cover": "istanbul cover --root src --print detail jasmine"

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/spec-cordova/pkgJson-restore.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/pkgJson-restore.spec.js b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
index d6bdbd5..cf42693 100644
--- a/cordova-lib/spec-cordova/pkgJson-restore.spec.js
+++ b/cordova-lib/spec-cordova/pkgJson-restore.spec.js
@@ -213,7 +213,7 @@ describe('tests platform/spec restore with --save', function () {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 
     /** Test#018
     *   When plugin is added with url and fetch and restored with fetch, 
@@ -287,7 +287,7 @@ describe('tests platform/spec restore with --save', function () {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson
@@ -393,7 +393,7 @@ describe('tests platform/spec restore with --save', function () {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson6 because pkg.json and config.xml contain only android
@@ -465,7 +465,7 @@ describe('files should not be modified if their platforms are identical',
functi
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use a new basePkgJson5 as config.xml contains android/browser and pkg.json contains android
@@ -550,7 +550,7 @@ describe('update pkg.json to include platforms in config.xml', function
() {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson3 as it has 'android' in config.xml and pkg.json (no cordova key).
@@ -629,7 +629,7 @@ describe('update empty package.json to match config.xml', function ()
{
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
  });
 
 // Use a new basePkgJson4 as pkg.json contains android/browser and config.xml contains android.
@@ -715,7 +715,7 @@ describe('update config.xml to include platforms in pkg.json', function
() {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Plugin testing begins here.
@@ -742,7 +742,6 @@ describe('update config.xml to use the variable found in pkg.json', function
()
         process.chdir(path.join(__dirname, '..'));  // Needed to rm the dir on Windows.
         shell.rm('-rf', tmpDir);
     });
-    
     // Factoring out some repeated checks.
     function emptyPlatformList() {
         return cordova.raw.platform('list').then(function() {
@@ -802,7 +801,7 @@ describe('update config.xml to use the variable found in pkg.json', function
()
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson9 as config contains 1 plugin and 1 variable and pkg.json contains 1 plugin
0 var
@@ -888,7 +887,7 @@ describe('update pkg.json to include plugin and variable found in config.xml',
f
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson10 as pkg.json contains (camera plugin: var 1/var 2, splashscreen plugin).

@@ -1011,7 +1010,7 @@ describe('update pkg.json AND config.xml to include all plugins and
merge unique
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson11 as pkg.json contains(splashscreen plugin, camera plugin: var1, value1,
var2, value2) and
@@ -1154,7 +1153,7 @@ describe('update pkg.json AND config.xml to include all plugins/merge
variables
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson12 as config.xml has 0 plugins and pkg.json has 1.
@@ -1254,7 +1253,7 @@ describe('update config.xml to include the plugin that is in pkg.json',
function
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 // Use basePkgJson13 - does NOT have a package.json
@@ -1398,7 +1397,7 @@ describe('platforms and plugins should be restored with config.xml even
without
         expect(err).toBeUndefined();
     }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 });
 
 
@@ -1496,7 +1495,7 @@ describe('tests platform/spec restore with --save', function () {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
+    },TIMEOUT);
 
     /** Test#002 will add two platforms to package.json with the 'save' flag.
     *   It will remove one platform from pkg.json without the 'save' flag and remove
@@ -1565,5 +1564,5 @@ describe('tests platform/spec restore with --save', function () {
             expect(err).toBeUndefined();
         }).fin(done);
     // Cordova prepare needs extra wait time to complete.
-},TIMEOUT);
-});
+    },TIMEOUT);
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/spec-cordova/platform.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/platform.spec.js b/cordova-lib/spec-cordova/platform.spec.js
index fd6416a..763ba9c 100644
--- a/cordova-lib/spec-cordova/platform.spec.js
+++ b/cordova-lib/spec-cordova/platform.spec.js
@@ -353,5 +353,4 @@ describe('plugin add and rm end-to-end --fetch', function () {
         })
         .fin(done);
     }, 60000);
-});
-
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index f77b945..2d5ab88 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -145,8 +145,6 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
             }).then(function(platDetails) {
                 if(fs.existsSync(path.join(projectRoot, 'package.json'))) {
                     delete require.cache[require.resolve(path.join(projectRoot, 'package.json'))];
-                    var pkgJson;
-                    pkgJson = require(path.join(projectRoot, 'package.json'));
                 }
                 platform = platDetails.platform;
                 var platformPath = path.join(projectRoot, 'platforms', platform);
@@ -275,7 +273,6 @@ function addHelper(cmd, hooksRunner, projectRoot, targets, opts) {
             if(fs.existsSync(pkgJsonPath)) {
                 delete require.cache[require.resolve(pkgJsonPath)]; 
                 pkgJson = require(pkgJsonPath);
-
             } else {
                 // TODO: Create package.json in cordova@7
             }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index 15492df..121fc0f 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -412,15 +412,26 @@ function determinePluginTarget(projectRoot, cfg, target, fetchOptions)
{
 
     // If parsedSpec.version satisfies pkgJson version, no writing to pkg.json. Only write
when
     // it does not satisfy.
+    
     if(parsedSpec.version) {
         if(pkgJson && pkgJson.dependencies && pkgJson.dependencies[parsedSpec.package])
{
-            var noSymbolVersion;
+            var noSymbolVersion = parsedSpec.version;
             if (parsedSpec.version.charAt(0) === '^' || parsedSpec.version.charAt(0) ===
'~') {
                 noSymbolVersion = parsedSpec.version.slice(1);
             }
-            if (!semver.satisfies(noSymbolVersion, pkgJson.dependencies[parsedSpec.package]))
{
+
+            if(cordova_util.isUrl(parsedSpec.version) || cordova_util.isDirectory(parsedSpec.version))
{
+                if (pkgJson.dependencies[parsedSpec.package] !== parsedSpec.version) {
+                    pkgJson.dependencies[parsedSpec.package] = parsedSpec.version;
+                }
+                if(fetchOptions.save === true) {
+                    fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 4), 'utf8');
+                }
+            } else if (!semver.satisfies(noSymbolVersion, pkgJson.dependencies[parsedSpec.package]))
{
                 pkgJson.dependencies[parsedSpec.package] = parsedSpec.version;
-                fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 4), 'utf8');
+                if (fetchOptions.save === true) {
+                    fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 4), 'utf8');
+                }
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b0402b9e/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index b55bbfc..954c333 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -71,7 +71,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
                 options.subdir = result[2];
             //if --fetch was used, throw error for subdirectories
 
-            if(options.subdir) {
+            if (options.subdir && options.subdir !== '.') {
                 events.emit('warn', 'support for subdirectories is deprecated and will be
removed in Cordova@7');
                 if (options.fetch) {
                     return Q.reject(new CordovaError('--fetch does not support subdirectories'));
@@ -116,7 +116,7 @@ function fetchPlugin(plugin_src, plugins_dir, options) {
                 };
             });
         }
-            // If it's not a network URL, it's either a local path or a plugin ID.
+        // If it's not a network URL, it's either a local path or a plugin ID.
         var plugin_dir = cordovaUtil.fixRelativePath(path.join(plugin_src, options.subdir));
         return Q.when().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