Repository: cordova-fetch
Updated Branches:
  refs/heads/master 086ca2999 -> d54b2465e


CB-13308, CB-13252 fix issue with plugins turning into symlinks on restore


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

Branch: refs/heads/master
Commit: d54b2465e99f6ebd11642d5cc9237d8674d732ca
Parents: 086ca29
Author: Steve Gill <[email protected]>
Authored: Mon Oct 2 22:54:41 2017 -0700
Committer: Steve Gill <[email protected]>
Committed: Mon Oct 2 22:57:49 2017 -0700

----------------------------------------------------------------------
 index.js                | 19 +++++++++++--------
 spec/fetch-unit.spec.js |  4 ++--
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-fetch/blob/d54b2465/index.js
----------------------------------------------------------------------
diff --git a/index.js b/index.js
index 60a3176..16ec031 100644
--- a/index.js
+++ b/index.js
@@ -41,6 +41,7 @@ module.exports = function (target, dest, opts) {
     opts = opts || {};
     var tree1;
     opts.production = opts.production || true;
+    var nodeModulesDir = dest;
 
     // check if npm is installed
     return module.exports.isNpmInstalled()
@@ -49,13 +50,13 @@ module.exports = function (target, dest, opts) {
                 // add target to fetchArgs Array
                 fetchArgs.push(target);
 
-                // append node_modules to dest if it doesn't come included
+                // append node_modules to nodeModulesDir if it doesn't come 
included
                 if (path.basename(dest) !== 'node_modules') {
-                    dest = path.resolve(path.join(dest, 'node_modules'));
+                    nodeModulesDir = path.resolve(path.join(dest, 
'node_modules'));
                 }
-                // create dest if it doesn't exist
-                if (!fs.existsSync(dest)) {
-                    shell.mkdir('-p', dest);
+                // create node_modules if it doesn't exist
+                if (!fs.existsSync(nodeModulesDir)) {
+                    shell.mkdir('-p', nodeModulesDir);
                 }
             } else return Q.reject(new CordovaError('Need to supply a target 
and destination'));
 
@@ -70,10 +71,12 @@ module.exports = function (target, dest, opts) {
             if (opts.save) {
                 events.emit('verbose', 'saving');
                 fetchArgs.push('--save');
+            } else {
+                fetchArgs.push('--no-save');
             }
 
             // Grab json object of installed modules before npm install
-            return depls(dest);
+            return depls(nodeModulesDir);
         })
         .then(function (depTree) {
             tree1 = depTree;
@@ -83,7 +86,7 @@ module.exports = function (target, dest, opts) {
         })
         .then(function (output) {
             // Grab object of installed modules after npm install
-            return depls(dest);
+            return depls(nodeModulesDir);
         })
         .then(function (depTree2) {
             var tree2 = depTree2;
@@ -93,7 +96,7 @@ module.exports = function (target, dest, opts) {
             // This could happen on a platform update.
             var id = getJsonDiff(tree1, tree2) || trimID(target);
 
-            return module.exports.getPath(id, dest, target);
+            return module.exports.getPath(id, nodeModulesDir, target);
         })
         .fail(function (err) {
             return Q.reject(new CordovaError(err));

http://git-wip-us.apache.org/repos/asf/cordova-fetch/blob/d54b2465/spec/fetch-unit.spec.js
----------------------------------------------------------------------
diff --git a/spec/fetch-unit.spec.js b/spec/fetch-unit.spec.js
index faf53c7..d5ee719 100644
--- a/spec/fetch-unit.spec.js
+++ b/spec/fetch-unit.spec.js
@@ -33,10 +33,10 @@ describe('unit tests for index.js', function () {
     });
 
     it('npm install should be called with production flag (default)', function 
(done) {
-        var opts = { cwd: 'some/path', production: true };
+        var opts = { cwd: 'some/path', production: true, save: true};
         fetch('platform', 'tmpDir', opts)
             .then(function (result) {
-                expect(superspawn.spawn).toHaveBeenCalledWith('npm', [ 
'install', 'platform', '--production' ], jasmine.any(Object));
+                expect(superspawn.spawn).toHaveBeenCalledWith('npm', [ 
'install', 'platform', '--production', '--save'], jasmine.any(Object));
             })
             .fail(function (err) {
                 console.error(err);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to