CB-13303 : updating opts.production
This closes #6
diff --git a/index.js b/index.js
index 1125cc8..4284ad4 100644
--- a/index.js
+++ b/index.js
@@ -40,9 +40,7 @@
var fetchArgs = opts.link ? ['link'] : ['install'];
opts = opts || {};
var tree1;
- opts.production = opts.production || true;
var nodeModulesDir = dest;
- opts.save_exact = opts.save_exact || false;
// check if npm is installed
return module.exports.isNpmInstalled()
@@ -64,8 +62,10 @@
// set the directory where npm install will be run
opts.cwd = dest;
// npm should use production by default when install is npm run
- if (opts.production) {
+
+ if ((opts.production) || (opts.production === undefined)) {
fetchArgs.push('--production');
+ opts.production = true;
}
// if user added --save flag, pass it to npm install command
@@ -78,7 +78,6 @@
} else {
fetchArgs.push('--no-save');
}
-
// Grab json object of installed modules before npm install
return depls(nodeModulesDir);
})
diff --git a/spec/fetch-unit.spec.js b/spec/fetch-unit.spec.js
index b980ad1..a8c206d 100644
--- a/spec/fetch-unit.spec.js
+++ b/spec/fetch-unit.spec.js
@@ -57,4 +57,17 @@
})
.fin(done);
});
+
+ it('noprod should turn production off', function (done) {
+ var opts = { cwd: 'some/path', production: false};
+ fetch('platform', 'tmpDir', opts)
+ .then(function (result) {
+ expect(superspawn.spawn).not.toHaveBeenCalledWith('npm', jasmine.stringMatching(/production/), jasmine.any(Object));
+ })
+ .fail(function (err) {
+ console.error(err);
+ expect(err).toBeUndefined();
+ })
+ .fin(done);
+ });
});