Save platforms and plugins to devDependencies
diff --git a/index.js b/index.js
index c5c03ad..b17d3dc 100644
--- a/index.js
+++ b/index.js
@@ -72,18 +72,14 @@
.then(spec => pathToInstalledPackage(spec, dest));
}
-function npmArgs (target, userOptions) {
- const opts = Object.assign({ production: true }, userOptions);
-
+function npmArgs (target, opts) {
const args = ['install', target];
+ opts = opts || {};
- if (opts.production) {
- args.push('--production');
- }
if (opts.save_exact) {
args.push('--save-exact');
} else if (opts.save) {
- args.push('--save');
+ args.push('--save-dev');
} else {
args.push('--no-save');
}
@@ -171,9 +167,9 @@
// set the directory where npm uninstall will be run
opts.cwd = dest;
- // if user added --save flag, pass it to npm uninstall command
+ // if user added --save flag, pass --save-dev flag to npm uninstall command
if (opts.save) {
- fetchArgs.push('--save');
+ fetchArgs.push('--save-dev');
} else {
fetchArgs.push('--no-save');
}
diff --git a/spec/fetch-unit.spec.js b/spec/fetch-unit.spec.js
index fff3981..3e26821 100644
--- a/spec/fetch-unit.spec.js
+++ b/spec/fetch-unit.spec.js
@@ -57,23 +57,18 @@
npmArgs('platform');
});
- it('npm install should be called with production flag (default)', function () {
- var opts = { cwd: 'some/path', production: true, save: true };
- expect(npmArgs('platform', opts)).toContain('--production');
- });
-
- it('save-exact should be true if passed in', function () {
+ it('when save_exact is true, save-exact flag should be passed through to npm', function () {
var opts = { cwd: 'some/path', save_exact: true };
expect(npmArgs('platform', opts)).toContain('--save-exact');
});
- it('noprod should turn production off', function () {
- var opts = { cwd: 'some/path', production: false };
- expect(npmArgs('platform', opts)).not.toContain('--production');
+ it('when save is true, save-dev flag should be passed through to npm', function () {
+ var opts = { cwd: 'some/path', save: true };
+ expect(npmArgs('platform', opts)).toContain('--save-dev');
});
- it('when save is false, no-save flag should be passed through', function () {
- var opts = { cwd: 'some/path', production: true, save: false };
+ it('when save is false, no-save flag should be passed through to npm', function () {
+ var opts = { cwd: 'some/path', save: false };
expect(npmArgs('platform', opts)).toContain('--no-save');
});
});
diff --git a/spec/fetch.spec.js b/spec/fetch.spec.js
index 2dfa087..6cb7846 100644
--- a/spec/fetch.spec.js
+++ b/spec/fetch.spec.js
@@ -55,9 +55,9 @@
expect(fs.existsSync(path.join(tmpDir, 'node_modules', pkgName))).toBe(false);
}
-function expectDependenciesToBe (deps) {
+function expectDevDependenciesToBe (deps) {
const rootPJ = fs.readJsonSync(path.join(tmpDir, 'package.json'));
- expect(rootPJ.dependencies).toEqual(deps);
+ expect(rootPJ.devDependencies).toEqual(deps);
}
describe('fetch/uninstall tests via npm & git', function () {
@@ -93,9 +93,9 @@
name: 'cordova-android',
version: '8.1.0'
}))
- .then(_ => expectDependenciesToBe({ 'cordova-android': '^8.1.0' }))
+ .then(_ => expectDevDependenciesToBe({ 'cordova-android': '^8.1.0' }))
.then(_ => uninstall('cordova-android', tmpDir, opts))
- .then(_ => expectDependenciesToBe({}))
+ .then(_ => expectDevDependenciesToBe({}))
.then(_ => expectNotToBeInstalled('cordova-android'))
// git tag
@@ -103,9 +103,9 @@
name: 'cordova-ios',
version: '5.0.1'
}))
- .then(_ => expectDependenciesToBe({ 'cordova-ios': 'git+https://github.com/apache/cordova-ios.git#rel/5.0.1' }))
+ .then(_ => expectDevDependenciesToBe({ 'cordova-ios': 'git+https://github.com/apache/cordova-ios.git#rel/5.0.1' }))
.then(_ => uninstall('cordova-ios', tmpDir, opts))
- .then(_ => expectDependenciesToBe({}))
+ .then(_ => expectDevDependenciesToBe({}))
.then(_ => expectNotToBeInstalled('cordova-ios'))
// git branch
@@ -113,7 +113,7 @@
name: 'cordova-android',
version: '4.1.1'
}))
- .then(_ => expectDependenciesToBe({ 'cordova-android': 'git+https://github.com/apache/cordova-android.git#4.1.x' }))
+ .then(_ => expectDevDependenciesToBe({ 'cordova-android': 'git+https://github.com/apache/cordova-android.git#4.1.x' }))
.then(_ => uninstall('cordova-android', tmpDir, opts));
}, 150000);
@@ -124,9 +124,9 @@
name: 'cordova-plugin-contacts',
version: '2.0.2-dev'
}))
- .then(_ => expectDependenciesToBe({ 'cordova-plugin-contacts': `git+${URL}` }))
+ .then(_ => expectDevDependenciesToBe({ 'cordova-plugin-contacts': `git+${URL}` }))
.then(_ => uninstall('cordova-plugin-contacts', tmpDir, opts))
- .then(_ => expectDependenciesToBe({}))
+ .then(_ => expectDevDependenciesToBe({}))
.then(_ => expectNotToBeInstalled('cordova-plugin-contacts'));
}, 30000);
});