@modernpoacher/deps 1.4.15 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/install/index.js +1 -1
- package/package.json +1 -1
- package/src/common/index.js +12 -0
- package/src/index.js +70 -80
- package/src/install/index.js +12 -14
- package/test/index.spec.js +288 -0
- package/test/install/index.spec.js +154 -0
package/lib/common/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCommands=exports.getBundleDependencies=exports.REGISTRY=exports.NVM=exports.DIRECTORY=void 0;exports.getDeps=getDeps;exports.getDepsExact=getDepsExact;exports.isExact=exports.getSaveProdParameter=exports.getSaveOptionalParameter=exports.getSaveExactParameter=exports.getSaveDevParameter=exports.getSaveBundleParameter=exports.getRegistryParameter=exports.getProdDependencies=exports.getPeerDependencies=exports.getOptionalDependencies=exports.getNoSaveParameter=exports.getDevDependencies=void 0;exports.normalise=normalise;exports.transform=transform;exports.transformDependency=void 0;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _path=require("path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`common\` (${_os.platform}) is awake`);const{path:MODULE_PATH}=module;const DIRECTORY='.';exports.DIRECTORY=DIRECTORY;const REGISTRY='https://registry.npmjs.org';exports.REGISTRY=REGISTRY;const NVM=(0,_path.resolve)(MODULE_PATH,'../../nvm.sh');exports.NVM=NVM;const getSaveProdParameter=commands=>commands.concat(' --save-prod');exports.getSaveProdParameter=getSaveProdParameter;const getSaveDevParameter=commands=>commands.concat(' --save-dev');exports.getSaveDevParameter=getSaveDevParameter;const getSaveBundleParameter=commands=>commands.concat(' --save-bundle');exports.getSaveBundleParameter=getSaveBundleParameter;const getSaveOptionalParameter=commands=>commands.concat(' --save-optional');exports.getSaveOptionalParameter=getSaveOptionalParameter;const getRegistryParameter=(r,commands)=>r?commands.concat(` --registry ${r}`):commands;exports.getRegistryParameter=getRegistryParameter;const getNoSaveParameter=(s,commands)=>s?commands:commands.concat(' --no-save');exports.getNoSaveParameter=getNoSaveParameter;const getSaveExactParameter=commands=>commands.concat(' --save-exact');exports.getSaveExactParameter=getSaveExactParameter;const getCommands=(directory=DIRECTORY,commands='npm i')=>`
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCommands=exports.getBundleDependencies=exports.REGISTRY=exports.NVM=exports.DIRECTORY=void 0;exports.getDeps=getDeps;exports.getDepsExact=getDepsExact;exports.isExact=exports.getSaveProdParameter=exports.getSaveOptionalParameter=exports.getSaveExactParameter=exports.getSaveDevParameter=exports.getSaveBundleParameter=exports.getRegistryParameter=exports.getProdDependencies=exports.getPeerDependencies=exports.getOptionalDependencies=exports.getNoSaveParameter=exports.getForceParameter=exports.getDevDependencies=void 0;exports.normalise=normalise;exports.transform=transform;exports.transformDependency=void 0;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _path=require("path");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`common\` (${_os.platform}) is awake`);const{path:MODULE_PATH}=module;const DIRECTORY='.';exports.DIRECTORY=DIRECTORY;const REGISTRY='https://registry.npmjs.org';exports.REGISTRY=REGISTRY;const NVM=(0,_path.resolve)(MODULE_PATH,'../../nvm.sh');exports.NVM=NVM;const getSaveProdParameter=commands=>commands.concat(' --save-prod');exports.getSaveProdParameter=getSaveProdParameter;const getSaveDevParameter=commands=>commands.concat(' --save-dev');exports.getSaveDevParameter=getSaveDevParameter;const getSaveBundleParameter=commands=>commands.concat(' --save-bundle');exports.getSaveBundleParameter=getSaveBundleParameter;const getSaveOptionalParameter=commands=>commands.concat(' --save-optional');exports.getSaveOptionalParameter=getSaveOptionalParameter;const getRegistryParameter=(r,commands)=>r?commands.concat(` --registry ${r}`):commands;exports.getRegistryParameter=getRegistryParameter;const getForceParameter=(f,commands)=>f?commands.concat(' --force'):commands;exports.getForceParameter=getForceParameter;const getNoSaveParameter=(s,commands)=>s?commands:commands.concat(' --no-save');exports.getNoSaveParameter=getNoSaveParameter;const getSaveExactParameter=commands=>commands.concat(' --save-exact');exports.getSaveExactParameter=getSaveExactParameter;const getCommands=(directory=DIRECTORY,commands='npm i')=>`
|
|
2
2
|
export PATH=/usr/local/bin:$PATH &> /dev/null
|
|
3
3
|
|
|
4
4
|
cd "${directory}"
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.executeBundle=executeBundle;exports.executeDev=executeDev;exports.executeOptional=executeOptional;exports.executeProd=executeProd;exports.getInstallCommands=void 0;exports.getInstallSaveBundleCommands=getInstallSaveBundleCommands;exports.getInstallSaveBundleSaveExactCommands=getInstallSaveBundleSaveExactCommands;exports.getInstallSaveDevCommands=getInstallSaveDevCommands;exports.getInstallSaveDevSaveExactCommands=getInstallSaveDevSaveExactCommands;exports.getInstallSaveExactCommands=void 0;exports.getInstallSaveOptionalCommands=getInstallSaveOptionalCommands;exports.getInstallSaveOptionalSaveExactCommands=getInstallSaveOptionalSaveExactCommands;exports.getInstallSaveProdCommands=getInstallSaveProdCommands;exports.getInstallSaveProdSaveExactCommands=getInstallSaveProdSaveExactCommands;exports.installSaveBundle=installSaveBundle;exports.installSaveBundleSaveExact=installSaveBundleSaveExact;exports.installSaveDev=installSaveDev;exports.installSaveDevSaveExact=installSaveDevSaveExact;exports.installSaveOptional=installSaveOptional;exports.installSaveOptionalSaveExact=installSaveOptionalSaveExact;exports.installSaveProd=installSaveProd;exports.installSaveProdSaveExact=installSaveProdSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("./common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`deps\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.executeBundle=executeBundle;exports.executeDev=executeDev;exports.executeOptional=executeOptional;exports.executeProd=executeProd;exports.getInstallCommands=void 0;exports.getInstallSaveBundleCommands=getInstallSaveBundleCommands;exports.getInstallSaveBundleSaveExactCommands=getInstallSaveBundleSaveExactCommands;exports.getInstallSaveDevCommands=getInstallSaveDevCommands;exports.getInstallSaveDevSaveExactCommands=getInstallSaveDevSaveExactCommands;exports.getInstallSaveExactCommands=void 0;exports.getInstallSaveOptionalCommands=getInstallSaveOptionalCommands;exports.getInstallSaveOptionalSaveExactCommands=getInstallSaveOptionalSaveExactCommands;exports.getInstallSaveProdCommands=getInstallSaveProdCommands;exports.getInstallSaveProdSaveExactCommands=getInstallSaveProdSaveExactCommands;exports.installSaveBundle=installSaveBundle;exports.installSaveBundleSaveExact=installSaveBundleSaveExact;exports.installSaveDev=installSaveDev;exports.installSaveDevSaveExact=installSaveDevSaveExact;exports.installSaveOptional=installSaveOptional;exports.installSaveOptionalSaveExact=installSaveOptionalSaveExact;exports.installSaveProd=installSaveProd;exports.installSaveProdSaveExact=installSaveProdSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("./common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps');log(`\`deps\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,r,f)=>{log('getInstallSaveExactCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,(0,_common.getSaveExactParameter)(commands))));};exports.getInstallSaveExactCommands=getInstallSaveExactCommands;const getInstallCommands=(p,r,f)=>{log('getInstallCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,commands)));};exports.getInstallCommands=getInstallCommands;function getInstallSaveBundleSaveExactCommands(p,r,f){log('getInstallSaveBundleSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveBundleParameter)(commands));}function getInstallSaveBundleCommands(p,r,f){log('getInstallSaveBundleCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveBundleParameter)(commands));}function getInstallSaveOptionalSaveExactCommands(p,r,f){log('getInstallSaveOptionalSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveOptionalParameter)(commands));}function getInstallSaveOptionalCommands(p,r,f){log('getInstallSaveOptionalCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveOptionalParameter)(commands));}function getInstallSaveDevSaveExactCommands(p,r,f){log('getInstallSaveDevSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveDevParameter)(commands));}function getInstallSaveDevCommands(p,r,f){log('getInstallSaveDevCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveDevParameter)(commands));}function getInstallSaveProdSaveExactCommands(p,r,f){log('getInstallSaveProdSaveExactCommands');const commands=getInstallSaveExactCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveProdParameter)(commands));}function getInstallSaveProdCommands(p,r,f){log('getInstallSaveProdCommands');const commands=getInstallCommands(p,r,f);return(0,_common.normalise)((0,_common.getSaveProdParameter)(commands));}function installSaveBundleSaveExact(d,p,r,f){log('installSaveBundleSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveBundleSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveBundle(d,p,r,f){log('installSaveBundle');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveBundleCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveOptionalSaveExact(d,p,r,f){log('installSaveOptionalSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveOptionalSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveOptional(d,p,r,f){log('installSaveOptional');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveOptionalCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveDevSaveExact(d,p,r,f){log('installSaveDevSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveDevSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveDev(d,p,r,f){log('installSaveDev');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveDevCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveProdSaveExact(d,p,r,f){log('installSaveProdSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveProdSaveExactCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function installSaveProd(d,p,r,f){log('installSaveProd');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveProdCommands(p,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}async function executeBundle(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeBundle');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveBundleSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveBundle(directory,deps,registry,force);}async function executeOptional(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeOptional');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveOptionalSaveExact(directory,depsExact,registry);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveOptional(directory,deps,registry);}async function executeDev(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeDev');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveDevSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveDev(directory,deps,registry,force);}async function executeProd(directory=_common.DIRECTORY,packages={},configuration={},registry=_common.REGISTRY,force=false){log('executeProd');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveProdSaveExact(directory,depsExact,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await installSaveProd(directory,deps,registry,force);}
|
package/lib/install/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.execute=execute;exports.getInstallSaveExactCommands=exports.getInstallCommands=void 0;exports.install=install;exports.installSaveExact=installSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps:install');log(`\`install\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.execute=execute;exports.getInstallSaveExactCommands=exports.getInstallCommands=void 0;exports.install=install;exports.installSaveExact=installSaveExact;var _debug=_interopRequireDefault(require("debug"));var _os=require("os");var _child_process=require("child_process");var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const log=(0,_debug.default)('@modernpoacher/deps:install');log(`\`install\` (${_os.platform}) is awake`);const getInstallSaveExactCommands=(p,s,r,f)=>{log('getInstallSaveExactCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getNoSaveParameter)(s,(0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,(0,_common.getSaveExactParameter)(commands)))));};exports.getInstallSaveExactCommands=getInstallSaveExactCommands;const getInstallCommands=(p,s,r,f)=>{log('getInstallCommands');const commands=`npm i ${(0,_common.transform)(p)}`;return(0,_common.normalise)((0,_common.getNoSaveParameter)(s,(0,_common.getRegistryParameter)(r,(0,_common.getForceParameter)(f,commands))));};exports.getInstallCommands=getInstallCommands;function installSaveExact(d,p,s,r,f){log('installSaveExact');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallSaveExactCommands(p,s,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}function install(d,p,s,r,f){log('install');return new Promise((resolve,reject)=>{const commands=(0,_common.getCommands)(d,getInstallCommands(p,s,r,f));(0,_child_process.spawn)('/bin/bash',['-c',commands],{shell:true,stdio:'inherit'},e=>!e?resolve():reject(e)).on('close',resolve).on('error',reject);});}async function execute(directory=_common.DIRECTORY,packages={},configuration={},save=false,registry=_common.REGISTRY,force=false){log('execute');const depsExact=(0,_common.getDepsExact)(packages,configuration);if(depsExact.length)await installSaveExact(directory,depsExact,save,registry,force);const deps=(0,_common.getDeps)(packages);if(deps.length)await install(directory,deps,save,registry,force);}
|
package/package.json
CHANGED
package/src/common/index.js
CHANGED
|
@@ -78,6 +78,18 @@ export const getSaveOptionalParameter = (commands) => commands.concat(' --save-o
|
|
|
78
78
|
*/
|
|
79
79
|
export const getRegistryParameter = (r, commands) => r ? commands.concat(` --registry ${r}`) : commands
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @function getForceParameter
|
|
83
|
+
*
|
|
84
|
+
* Get the "force" parameter and argument
|
|
85
|
+
*
|
|
86
|
+
* @param {String} force
|
|
87
|
+
* @param {String} current commands string
|
|
88
|
+
*
|
|
89
|
+
* @return {String}
|
|
90
|
+
*/
|
|
91
|
+
export const getForceParameter = (f, commands) => f ? commands.concat(' --force') : commands
|
|
92
|
+
|
|
81
93
|
/**
|
|
82
94
|
* @function getNoSaveParameter
|
|
83
95
|
*
|
package/src/index.js
CHANGED
|
@@ -35,16 +35,15 @@ log(`\`deps\` (${platform}) is awake`)
|
|
|
35
35
|
* Get the `npm install --save-exact` commands as a string of parameters and arguments
|
|
36
36
|
*
|
|
37
37
|
* @param {Object} p - Packages
|
|
38
|
-
* @param {Object} c - Configuration
|
|
39
38
|
* @param {String} r - Registry
|
|
40
|
-
* @param {Boolean}
|
|
39
|
+
* @param {Boolean} f - Force
|
|
41
40
|
*
|
|
42
41
|
* @return {Array}
|
|
43
42
|
*/
|
|
44
|
-
export const getInstallSaveExactCommands = (p,
|
|
43
|
+
export const getInstallSaveExactCommands = (p, r, f) => {
|
|
45
44
|
log('getInstallSaveExactCommands')
|
|
46
45
|
|
|
47
|
-
const commands = `npm i ${transform(p
|
|
46
|
+
const commands = `npm i ${transform(p)}`
|
|
48
47
|
|
|
49
48
|
return normalise(
|
|
50
49
|
getRegistryParameter(r, getForceParameter(f, getSaveExactParameter(commands)))
|
|
@@ -57,16 +56,15 @@ export const getInstallSaveExactCommands = (p, c, r, f) => {
|
|
|
57
56
|
* Get the `npm install` commands as a string of parameters and arguments
|
|
58
57
|
*
|
|
59
58
|
* @param {Object} p - Packages
|
|
60
|
-
* @param {Object} c - Configuration
|
|
61
59
|
* @param {String} r - Registry
|
|
62
|
-
* @param {Boolean}
|
|
60
|
+
* @param {Boolean} f - Force
|
|
63
61
|
*
|
|
64
62
|
* @return {Array}
|
|
65
63
|
*/
|
|
66
|
-
export const getInstallCommands = (p,
|
|
64
|
+
export const getInstallCommands = (p, r, f) => {
|
|
67
65
|
log('getInstallCommands')
|
|
68
66
|
|
|
69
|
-
const commands = `npm i ${transform(p
|
|
67
|
+
const commands = `npm i ${transform(p)}`
|
|
70
68
|
|
|
71
69
|
return normalise(
|
|
72
70
|
getRegistryParameter(r, getForceParameter(f, commands))
|
|
@@ -79,16 +77,15 @@ export const getInstallCommands = (p, c, r, f) => {
|
|
|
79
77
|
* Get the `npm install --save-bundle --save-exact` commands as a string of parameters and arguments
|
|
80
78
|
*
|
|
81
79
|
* @param {Object} p - Packages
|
|
82
|
-
* @param {Object} c - Configuration
|
|
83
80
|
* @param {String} r - Registry
|
|
84
|
-
* @param {Boolean}
|
|
81
|
+
* @param {Boolean} f - Force
|
|
85
82
|
*
|
|
86
83
|
* @return {Array}
|
|
87
84
|
*/
|
|
88
|
-
export function getInstallSaveBundleSaveExactCommands (p,
|
|
85
|
+
export function getInstallSaveBundleSaveExactCommands (p, r, f) {
|
|
89
86
|
log('getInstallSaveBundleSaveExactCommands')
|
|
90
87
|
|
|
91
|
-
const commands = getInstallSaveExactCommands(p,
|
|
88
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
92
89
|
|
|
93
90
|
return normalise(
|
|
94
91
|
getSaveBundleParameter(commands)
|
|
@@ -101,16 +98,15 @@ export function getInstallSaveBundleSaveExactCommands (p, c, r, f) {
|
|
|
101
98
|
* Get the `npm install --save-bundle` commands as a string of parameters and arguments
|
|
102
99
|
*
|
|
103
100
|
* @param {Object} p - Packages
|
|
104
|
-
* @param {Object} c - Configuration
|
|
105
101
|
* @param {String} r - Registry
|
|
106
|
-
* @param {Boolean}
|
|
102
|
+
* @param {Boolean} f - Force
|
|
107
103
|
*
|
|
108
104
|
* @return {Array}
|
|
109
105
|
*/
|
|
110
|
-
export function getInstallSaveBundleCommands (p,
|
|
106
|
+
export function getInstallSaveBundleCommands (p, r, f) {
|
|
111
107
|
log('getInstallSaveBundleCommands')
|
|
112
108
|
|
|
113
|
-
const commands = getInstallCommands(p,
|
|
109
|
+
const commands = getInstallCommands(p, r, f)
|
|
114
110
|
|
|
115
111
|
return normalise(
|
|
116
112
|
getSaveBundleParameter(commands)
|
|
@@ -123,16 +119,15 @@ export function getInstallSaveBundleCommands (p, c, r, f) {
|
|
|
123
119
|
* Get the `npm install --save-optional --save-exact` commands as a string of parameters and arguments
|
|
124
120
|
*
|
|
125
121
|
* @param {Object} p - Packages
|
|
126
|
-
* @param {Object} c - Configuration
|
|
127
122
|
* @param {String} r - Registry
|
|
128
|
-
* @param {Boolean}
|
|
123
|
+
* @param {Boolean} f - Force
|
|
129
124
|
*
|
|
130
125
|
* @return {Array}
|
|
131
126
|
*/
|
|
132
|
-
export function getInstallSaveOptionalSaveExactCommands (p,
|
|
127
|
+
export function getInstallSaveOptionalSaveExactCommands (p, r, f) {
|
|
133
128
|
log('getInstallSaveOptionalSaveExactCommands')
|
|
134
129
|
|
|
135
|
-
const commands = getInstallSaveExactCommands(p,
|
|
130
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
136
131
|
|
|
137
132
|
return normalise(
|
|
138
133
|
getSaveOptionalParameter(commands)
|
|
@@ -145,16 +140,15 @@ export function getInstallSaveOptionalSaveExactCommands (p, c, r, f) {
|
|
|
145
140
|
* Get the `npm install --save-optional` commands as a string of parameters and arguments
|
|
146
141
|
*
|
|
147
142
|
* @param {Object} p - Packages
|
|
148
|
-
* @param {Object} c - Configuration
|
|
149
143
|
* @param {String} r - Registry
|
|
150
|
-
* @param {Boolean}
|
|
144
|
+
* @param {Boolean} f - Force
|
|
151
145
|
*
|
|
152
146
|
* @return {Array}
|
|
153
147
|
*/
|
|
154
|
-
export function getInstallSaveOptionalCommands (p,
|
|
148
|
+
export function getInstallSaveOptionalCommands (p, r, f) {
|
|
155
149
|
log('getInstallSaveOptionalCommands')
|
|
156
150
|
|
|
157
|
-
const commands = getInstallCommands(p,
|
|
151
|
+
const commands = getInstallCommands(p, r, f)
|
|
158
152
|
|
|
159
153
|
return normalise(
|
|
160
154
|
getSaveOptionalParameter(commands)
|
|
@@ -167,16 +161,15 @@ export function getInstallSaveOptionalCommands (p, c, r, f) {
|
|
|
167
161
|
* Get the `npm install --save-dev --save-exact` commands as a string of parameters and arguments
|
|
168
162
|
*
|
|
169
163
|
* @param {Object} p - Packages
|
|
170
|
-
* @param {Object} c - Configuration
|
|
171
164
|
* @param {String} r - Registry
|
|
172
|
-
* @param {Boolean}
|
|
165
|
+
* @param {Boolean} f - Force
|
|
173
166
|
*
|
|
174
167
|
* @return {Array}
|
|
175
168
|
*/
|
|
176
|
-
export function getInstallSaveDevSaveExactCommands (p,
|
|
169
|
+
export function getInstallSaveDevSaveExactCommands (p, r, f) {
|
|
177
170
|
log('getInstallSaveDevSaveExactCommands')
|
|
178
171
|
|
|
179
|
-
const commands = getInstallSaveExactCommands(p,
|
|
172
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
180
173
|
|
|
181
174
|
return normalise(
|
|
182
175
|
getSaveDevParameter(commands)
|
|
@@ -189,16 +182,15 @@ export function getInstallSaveDevSaveExactCommands (p, c, r, f) {
|
|
|
189
182
|
* Get the `npm install --save-dev` commands as a string of parameters and arguments
|
|
190
183
|
*
|
|
191
184
|
* @param {Object} p - Packages
|
|
192
|
-
* @param {Object} c - Configuration
|
|
193
185
|
* @param {String} r - Registry
|
|
194
|
-
* @param {Boolean}
|
|
186
|
+
* @param {Boolean} f - Force
|
|
195
187
|
*
|
|
196
188
|
* @return {Array}
|
|
197
189
|
*/
|
|
198
|
-
export function getInstallSaveDevCommands (p,
|
|
190
|
+
export function getInstallSaveDevCommands (p, r, f) {
|
|
199
191
|
log('getInstallSaveDevCommands')
|
|
200
192
|
|
|
201
|
-
const commands = getInstallCommands(p,
|
|
193
|
+
const commands = getInstallCommands(p, r, f)
|
|
202
194
|
|
|
203
195
|
return normalise(
|
|
204
196
|
getSaveDevParameter(commands)
|
|
@@ -211,16 +203,15 @@ export function getInstallSaveDevCommands (p, c, r, f) {
|
|
|
211
203
|
* Get the `npm install --save-prod --save-exact` commands as a string of parameters and arguments
|
|
212
204
|
*
|
|
213
205
|
* @param {Object} p - Packages
|
|
214
|
-
* @param {Object} c - Configuration
|
|
215
206
|
* @param {String} r - Registry
|
|
216
|
-
* @param {Boolean}
|
|
207
|
+
* @param {Boolean} f - Force
|
|
217
208
|
*
|
|
218
209
|
* @return {Array}
|
|
219
210
|
*/
|
|
220
|
-
export function getInstallSaveProdSaveExactCommands (p,
|
|
211
|
+
export function getInstallSaveProdSaveExactCommands (p, r, f) {
|
|
221
212
|
log('getInstallSaveProdSaveExactCommands')
|
|
222
213
|
|
|
223
|
-
const commands = getInstallSaveExactCommands(p,
|
|
214
|
+
const commands = getInstallSaveExactCommands(p, r, f)
|
|
224
215
|
|
|
225
216
|
return normalise(
|
|
226
217
|
getSaveProdParameter(commands)
|
|
@@ -233,16 +224,15 @@ export function getInstallSaveProdSaveExactCommands (p, c, r, f) {
|
|
|
233
224
|
* Get the `npm install --save-prod` commands as a string of parameters and arguments
|
|
234
225
|
*
|
|
235
226
|
* @param {Object} p - Packages
|
|
236
|
-
* @param {Object} c - Configuration
|
|
237
227
|
* @param {String} r - Registry
|
|
238
|
-
* @param {Boolean}
|
|
228
|
+
* @param {Boolean} f - Force
|
|
239
229
|
*
|
|
240
230
|
* @return {Array}
|
|
241
231
|
*/
|
|
242
|
-
export function getInstallSaveProdCommands (p,
|
|
232
|
+
export function getInstallSaveProdCommands (p, r, f) {
|
|
243
233
|
log('getInstallSaveProdCommands')
|
|
244
234
|
|
|
245
|
-
const commands = getInstallCommands(p,
|
|
235
|
+
const commands = getInstallCommands(p, r, f)
|
|
246
236
|
|
|
247
237
|
return normalise(
|
|
248
238
|
getSaveProdParameter(commands)
|
|
@@ -256,17 +246,17 @@ export function getInstallSaveProdCommands (p, c, r, f) {
|
|
|
256
246
|
*
|
|
257
247
|
* @param {String} d - Directory
|
|
258
248
|
* @param {Object} p - Packages
|
|
259
|
-
* @param {Object} c - Configuration
|
|
260
249
|
* @param {String} r - Registry
|
|
250
|
+
* @param {Boolean} f - Force
|
|
261
251
|
*
|
|
262
252
|
* @return {Promise}
|
|
263
253
|
*/
|
|
264
|
-
export function installSaveBundleSaveExact (d, p,
|
|
254
|
+
export function installSaveBundleSaveExact (d, p, r, f) {
|
|
265
255
|
log('installSaveBundleSaveExact')
|
|
266
256
|
|
|
267
257
|
return (
|
|
268
258
|
new Promise((resolve, reject) => {
|
|
269
|
-
const commands = getCommands(d, getInstallSaveBundleSaveExactCommands(p,
|
|
259
|
+
const commands = getCommands(d, getInstallSaveBundleSaveExactCommands(p, r, f))
|
|
270
260
|
|
|
271
261
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
272
262
|
.on('close', resolve)
|
|
@@ -282,17 +272,17 @@ export function installSaveBundleSaveExact (d, p, c, r, f) {
|
|
|
282
272
|
*
|
|
283
273
|
* @param {String} d - Directory
|
|
284
274
|
* @param {Object} p - Packages
|
|
285
|
-
* @param {Object} c - Configuration
|
|
286
275
|
* @param {String} r - Registry
|
|
276
|
+
* @param {Boolean} f - Force
|
|
287
277
|
*
|
|
288
278
|
* @return {Promise}
|
|
289
279
|
*/
|
|
290
|
-
export function installSaveBundle (d, p,
|
|
280
|
+
export function installSaveBundle (d, p, r, f) {
|
|
291
281
|
log('installSaveBundle')
|
|
292
282
|
|
|
293
283
|
return (
|
|
294
284
|
new Promise((resolve, reject) => {
|
|
295
|
-
const commands = getCommands(d, getInstallSaveBundleCommands(p,
|
|
285
|
+
const commands = getCommands(d, getInstallSaveBundleCommands(p, r, f))
|
|
296
286
|
|
|
297
287
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
298
288
|
.on('close', resolve)
|
|
@@ -308,17 +298,17 @@ export function installSaveBundle (d, p, c, r, f) {
|
|
|
308
298
|
*
|
|
309
299
|
* @param {String} d - Directory
|
|
310
300
|
* @param {Object} p - Packages
|
|
311
|
-
* @param {Object} c - Configuration
|
|
312
301
|
* @param {String} r - Registry
|
|
302
|
+
* @param {Boolean} f - Force
|
|
313
303
|
*
|
|
314
304
|
* @return {Promise}
|
|
315
305
|
*/
|
|
316
|
-
export function installSaveOptionalSaveExact (d, p,
|
|
306
|
+
export function installSaveOptionalSaveExact (d, p, r, f) {
|
|
317
307
|
log('installSaveOptionalSaveExact')
|
|
318
308
|
|
|
319
309
|
return (
|
|
320
310
|
new Promise((resolve, reject) => {
|
|
321
|
-
const commands = getCommands(d, getInstallSaveOptionalSaveExactCommands(p,
|
|
311
|
+
const commands = getCommands(d, getInstallSaveOptionalSaveExactCommands(p, r, f))
|
|
322
312
|
|
|
323
313
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
324
314
|
.on('close', resolve)
|
|
@@ -334,17 +324,17 @@ export function installSaveOptionalSaveExact (d, p, c, r, f) {
|
|
|
334
324
|
*
|
|
335
325
|
* @param {String} d - Directory
|
|
336
326
|
* @param {Object} p - Packages
|
|
337
|
-
* @param {Object} c - Configuration
|
|
338
327
|
* @param {String} r - Registry
|
|
328
|
+
* @param {Boolean} f - Force
|
|
339
329
|
*
|
|
340
330
|
* @return {Promise}
|
|
341
331
|
*/
|
|
342
|
-
export function installSaveOptional (d, p,
|
|
332
|
+
export function installSaveOptional (d, p, r, f) {
|
|
343
333
|
log('installSaveOptional')
|
|
344
334
|
|
|
345
335
|
return (
|
|
346
336
|
new Promise((resolve, reject) => {
|
|
347
|
-
const commands = getCommands(d, getInstallSaveOptionalCommands(p,
|
|
337
|
+
const commands = getCommands(d, getInstallSaveOptionalCommands(p, r, f))
|
|
348
338
|
|
|
349
339
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
350
340
|
.on('close', resolve)
|
|
@@ -360,17 +350,17 @@ export function installSaveOptional (d, p, c, r, f) {
|
|
|
360
350
|
*
|
|
361
351
|
* @param {String} d - Directory
|
|
362
352
|
* @param {Object} p - Packages
|
|
363
|
-
* @param {Object} c - Configuration
|
|
364
353
|
* @param {String} r - Registry
|
|
354
|
+
* @param {Boolean} f - Force
|
|
365
355
|
*
|
|
366
356
|
* @return {Promise}
|
|
367
357
|
*/
|
|
368
|
-
export function installSaveDevSaveExact (d, p,
|
|
358
|
+
export function installSaveDevSaveExact (d, p, r, f) {
|
|
369
359
|
log('installSaveDevSaveExact')
|
|
370
360
|
|
|
371
361
|
return (
|
|
372
362
|
new Promise((resolve, reject) => {
|
|
373
|
-
const commands = getCommands(d, getInstallSaveDevSaveExactCommands(p,
|
|
363
|
+
const commands = getCommands(d, getInstallSaveDevSaveExactCommands(p, r, f))
|
|
374
364
|
|
|
375
365
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
376
366
|
.on('close', resolve)
|
|
@@ -386,17 +376,17 @@ export function installSaveDevSaveExact (d, p, c, r, f) {
|
|
|
386
376
|
*
|
|
387
377
|
* @param {String} d - Directory
|
|
388
378
|
* @param {Object} p - Packages
|
|
389
|
-
* @param {Object} c - Configuration
|
|
390
379
|
* @param {String} r - Registry
|
|
380
|
+
* @param {Boolean} f - Force
|
|
391
381
|
*
|
|
392
382
|
* @return {Promise}
|
|
393
383
|
*/
|
|
394
|
-
export function installSaveDev (d, p,
|
|
384
|
+
export function installSaveDev (d, p, r, f) {
|
|
395
385
|
log('installSaveDev')
|
|
396
386
|
|
|
397
387
|
return (
|
|
398
388
|
new Promise((resolve, reject) => {
|
|
399
|
-
const commands = getCommands(d, getInstallSaveDevCommands(p,
|
|
389
|
+
const commands = getCommands(d, getInstallSaveDevCommands(p, r, f))
|
|
400
390
|
|
|
401
391
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
402
392
|
.on('close', resolve)
|
|
@@ -412,17 +402,17 @@ export function installSaveDev (d, p, c, r, f) {
|
|
|
412
402
|
*
|
|
413
403
|
* @param {String} d - Directory
|
|
414
404
|
* @param {Object} p - Packages
|
|
415
|
-
* @param {Object} c - Configuration
|
|
416
405
|
* @param {String} r - Registry
|
|
406
|
+
* @param {Boolean} f - Force
|
|
417
407
|
*
|
|
418
408
|
* @return {Promise}
|
|
419
409
|
*/
|
|
420
|
-
export function installSaveProdSaveExact (d, p,
|
|
410
|
+
export function installSaveProdSaveExact (d, p, r, f) {
|
|
421
411
|
log('installSaveProdSaveExact')
|
|
422
412
|
|
|
423
413
|
return (
|
|
424
414
|
new Promise((resolve, reject) => {
|
|
425
|
-
const commands = getCommands(d, getInstallSaveProdSaveExactCommands(p,
|
|
415
|
+
const commands = getCommands(d, getInstallSaveProdSaveExactCommands(p, r, f))
|
|
426
416
|
|
|
427
417
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
428
418
|
.on('close', resolve)
|
|
@@ -438,17 +428,17 @@ export function installSaveProdSaveExact (d, p, c, r, f) {
|
|
|
438
428
|
*
|
|
439
429
|
* @param {String} d - Directory
|
|
440
430
|
* @param {Object} p - Packages
|
|
441
|
-
* @param {Object} c - Configuration
|
|
442
431
|
* @param {String} r - Registry
|
|
432
|
+
* @param {Boolean} f - Force
|
|
443
433
|
*
|
|
444
434
|
* @return {Promise}
|
|
445
435
|
*/
|
|
446
|
-
export function installSaveProd (d, p,
|
|
436
|
+
export function installSaveProd (d, p, r, f) {
|
|
447
437
|
log('installSaveProd')
|
|
448
438
|
|
|
449
439
|
return (
|
|
450
440
|
new Promise((resolve, reject) => {
|
|
451
|
-
const commands = getCommands(d, getInstallSaveProdCommands(p,
|
|
441
|
+
const commands = getCommands(d, getInstallSaveProdCommands(p, r, f))
|
|
452
442
|
|
|
453
443
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
454
444
|
.on('close', resolve)
|
|
@@ -465,21 +455,21 @@ export function installSaveProd (d, p, c, r, f) {
|
|
|
465
455
|
* @param {String} d - Directory
|
|
466
456
|
* @param {Object} p - Packages
|
|
467
457
|
* @param {Object} c - Configuration
|
|
468
|
-
* @param {Boolean} s - Save
|
|
469
458
|
* @param {String} r - Registry
|
|
459
|
+
* @param {Boolean} f - Force
|
|
470
460
|
*
|
|
471
461
|
* @return {Promise}
|
|
472
462
|
*/
|
|
473
463
|
export async function executeBundle (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
474
464
|
log('executeBundle')
|
|
475
465
|
|
|
476
|
-
const
|
|
466
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
477
467
|
|
|
478
|
-
if (
|
|
468
|
+
if (depsExact.length) await installSaveBundleSaveExact(directory, depsExact, registry, force)
|
|
479
469
|
|
|
480
470
|
const deps = getDeps(packages)
|
|
481
471
|
|
|
482
|
-
if (deps.length) await installSaveBundle(directory, deps,
|
|
472
|
+
if (deps.length) await installSaveBundle(directory, deps, registry, force)
|
|
483
473
|
}
|
|
484
474
|
|
|
485
475
|
/**
|
|
@@ -490,21 +480,21 @@ export async function executeBundle (directory = DIRECTORY, packages = {}, confi
|
|
|
490
480
|
* @param {String} d - Directory
|
|
491
481
|
* @param {Object} p - Packages
|
|
492
482
|
* @param {Object} c - Configuration
|
|
493
|
-
* @param {Boolean} s - Save
|
|
494
483
|
* @param {String} r - Registry
|
|
484
|
+
* @param {Boolean} f - Force
|
|
495
485
|
*
|
|
496
486
|
* @return {Promise}
|
|
497
487
|
*/
|
|
498
488
|
export async function executeOptional (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
499
489
|
log('executeOptional')
|
|
500
490
|
|
|
501
|
-
const
|
|
491
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
502
492
|
|
|
503
|
-
if (
|
|
493
|
+
if (depsExact.length) await installSaveOptionalSaveExact(directory, depsExact, registry)
|
|
504
494
|
|
|
505
495
|
const deps = getDeps(packages)
|
|
506
496
|
|
|
507
|
-
if (deps.length) await installSaveOptional(directory, deps,
|
|
497
|
+
if (deps.length) await installSaveOptional(directory, deps, registry)
|
|
508
498
|
}
|
|
509
499
|
|
|
510
500
|
/**
|
|
@@ -515,21 +505,21 @@ export async function executeOptional (directory = DIRECTORY, packages = {}, con
|
|
|
515
505
|
* @param {String} d - Directory
|
|
516
506
|
* @param {Object} p - Packages
|
|
517
507
|
* @param {Object} c - Configuration
|
|
518
|
-
* @param {Boolean} s - Save
|
|
519
508
|
* @param {String} r - Registry
|
|
509
|
+
* @param {Boolean} f - Force
|
|
520
510
|
*
|
|
521
511
|
* @return {Promise}
|
|
522
512
|
*/
|
|
523
513
|
export async function executeDev (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
524
514
|
log('executeDev')
|
|
525
515
|
|
|
526
|
-
const
|
|
516
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
527
517
|
|
|
528
|
-
if (
|
|
518
|
+
if (depsExact.length) await installSaveDevSaveExact(directory, depsExact, registry, force)
|
|
529
519
|
|
|
530
520
|
const deps = getDeps(packages)
|
|
531
521
|
|
|
532
|
-
if (deps.length) await installSaveDev(directory, deps,
|
|
522
|
+
if (deps.length) await installSaveDev(directory, deps, registry, force)
|
|
533
523
|
}
|
|
534
524
|
|
|
535
525
|
/**
|
|
@@ -540,19 +530,19 @@ export async function executeDev (directory = DIRECTORY, packages = {}, configur
|
|
|
540
530
|
* @param {String} d - Directory
|
|
541
531
|
* @param {Object} p - Packages
|
|
542
532
|
* @param {Object} c - Configuration
|
|
543
|
-
* @param {Boolean} s - Save
|
|
544
533
|
* @param {String} r - Registry
|
|
534
|
+
* @param {Boolean} f - Force
|
|
545
535
|
*
|
|
546
536
|
* @return {Promise}
|
|
547
537
|
*/
|
|
548
538
|
export async function executeProd (directory = DIRECTORY, packages = {}, configuration = {}, registry = REGISTRY, force = false) {
|
|
549
539
|
log('executeProd')
|
|
550
540
|
|
|
551
|
-
const
|
|
541
|
+
const depsExact = getDepsExact(packages, configuration)
|
|
552
542
|
|
|
553
|
-
if (
|
|
543
|
+
if (depsExact.length) await installSaveProdSaveExact(directory, depsExact, registry, force)
|
|
554
544
|
|
|
555
545
|
const deps = getDeps(packages)
|
|
556
546
|
|
|
557
|
-
if (deps.length) await installSaveProd(directory, deps,
|
|
547
|
+
if (deps.length) await installSaveProd(directory, deps, registry, force)
|
|
558
548
|
}
|
package/src/install/index.js
CHANGED
|
@@ -32,17 +32,16 @@ log(`\`install\` (${platform}) is awake`)
|
|
|
32
32
|
* Get the `install --save-exact` commands as a string of parameters and arguments
|
|
33
33
|
*
|
|
34
34
|
* @param {Object} p - Packages
|
|
35
|
-
* @param {Object} c - Configuration
|
|
36
35
|
* @param {Boolean} s - Save
|
|
37
36
|
* @param {String} r - Registry
|
|
38
|
-
* @param {Boolean}
|
|
37
|
+
* @param {Boolean} f - Force
|
|
39
38
|
*
|
|
40
39
|
* @return {Array}
|
|
41
40
|
*/
|
|
42
|
-
export const getInstallSaveExactCommands = (p,
|
|
41
|
+
export const getInstallSaveExactCommands = (p, s, r, f) => {
|
|
43
42
|
log('getInstallSaveExactCommands')
|
|
44
43
|
|
|
45
|
-
const commands = `npm i ${transform(p
|
|
44
|
+
const commands = `npm i ${transform(p)}`
|
|
46
45
|
|
|
47
46
|
return normalise(
|
|
48
47
|
getNoSaveParameter(s, getRegistryParameter(r, getForceParameter(f, getSaveExactParameter(commands))))
|
|
@@ -55,17 +54,16 @@ export const getInstallSaveExactCommands = (p, c, s, r, f) => {
|
|
|
55
54
|
* Get the `install` commands as a string of parameters and arguments
|
|
56
55
|
*
|
|
57
56
|
* @param {Object} p - Packages
|
|
58
|
-
* @param {Object} c - Configuration
|
|
59
57
|
* @param {Boolean} s - Save
|
|
60
58
|
* @param {String} r - Registry
|
|
61
|
-
* @param {Boolean}
|
|
59
|
+
* @param {Boolean} f - Force
|
|
62
60
|
*
|
|
63
61
|
* @return {Array}
|
|
64
62
|
*/
|
|
65
|
-
export const getInstallCommands = (p,
|
|
63
|
+
export const getInstallCommands = (p, s, r, f) => {
|
|
66
64
|
log('getInstallCommands')
|
|
67
65
|
|
|
68
|
-
const commands = `npm i ${transform(p
|
|
66
|
+
const commands = `npm i ${transform(p)}`
|
|
69
67
|
|
|
70
68
|
return normalise(
|
|
71
69
|
getNoSaveParameter(s, getRegistryParameter(r, getForceParameter(f, commands)))
|
|
@@ -85,12 +83,12 @@ export const getInstallCommands = (p, c, s, r, f) => {
|
|
|
85
83
|
*
|
|
86
84
|
* @return {Promise}
|
|
87
85
|
*/
|
|
88
|
-
export function installSaveExact (d, p,
|
|
86
|
+
export function installSaveExact (d, p, s, r, f) {
|
|
89
87
|
log('installSaveExact')
|
|
90
88
|
|
|
91
89
|
return (
|
|
92
90
|
new Promise((resolve, reject) => {
|
|
93
|
-
const commands = getCommands(d, getInstallSaveExactCommands(p,
|
|
91
|
+
const commands = getCommands(d, getInstallSaveExactCommands(p, s, r, f))
|
|
94
92
|
|
|
95
93
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
96
94
|
.on('close', resolve)
|
|
@@ -112,12 +110,12 @@ export function installSaveExact (d, p, c, s, r, f) {
|
|
|
112
110
|
*
|
|
113
111
|
* @return {Promise}
|
|
114
112
|
*/
|
|
115
|
-
export function install (d, p,
|
|
113
|
+
export function install (d, p, s, r, f) {
|
|
116
114
|
log('install')
|
|
117
115
|
|
|
118
116
|
return (
|
|
119
117
|
new Promise((resolve, reject) => {
|
|
120
|
-
const commands = getCommands(d, getInstallCommands(p,
|
|
118
|
+
const commands = getCommands(d, getInstallCommands(p, s, r, f))
|
|
121
119
|
|
|
122
120
|
spawn('/bin/bash', ['-c', commands], { shell: true, stdio: 'inherit' }, (e) => (!e) ? resolve() : reject(e))
|
|
123
121
|
.on('close', resolve)
|
|
@@ -144,9 +142,9 @@ export async function execute (directory = DIRECTORY, packages = {}, configurati
|
|
|
144
142
|
|
|
145
143
|
const depsExact = getDepsExact(packages, configuration)
|
|
146
144
|
|
|
147
|
-
if (depsExact.length) await installSaveExact(directory, depsExact,
|
|
145
|
+
if (depsExact.length) await installSaveExact(directory, depsExact, save, registry, force)
|
|
148
146
|
|
|
149
147
|
const deps = getDeps(packages)
|
|
150
148
|
|
|
151
|
-
if (deps.length) await install(directory, deps,
|
|
149
|
+
if (deps.length) await install(directory, deps, save, registry, force)
|
|
152
150
|
}
|
package/test/index.spec.js
CHANGED
|
@@ -191,4 +191,292 @@ describe('@modernpoacher/deps', () => {
|
|
|
191
191
|
.to.be.a('function')
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
|
+
|
|
195
|
+
describe('`getInstallSaveProdSaveExactCommands()`', () => {
|
|
196
|
+
describe('Always', () => {
|
|
197
|
+
it('returns a string', () => {
|
|
198
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
199
|
+
|
|
200
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES))
|
|
201
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-prod')
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
describe('Registry is defined', () => {
|
|
206
|
+
it('returns a string', () => {
|
|
207
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
208
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
209
|
+
|
|
210
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
211
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-prod')
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
describe('Force is true', () => {
|
|
215
|
+
it('returns a string', () => {
|
|
216
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
217
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
218
|
+
const MOCK_FORCE = true
|
|
219
|
+
|
|
220
|
+
return expect(getInstallSaveProdSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
221
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-prod')
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
describe('`getInstallSaveDevSaveExactCommands()`', () => {
|
|
228
|
+
describe('Always', () => {
|
|
229
|
+
it('returns a string', () => {
|
|
230
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
231
|
+
|
|
232
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES))
|
|
233
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-dev')
|
|
234
|
+
})
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
describe('Registry is defined', () => {
|
|
238
|
+
it('returns a string', () => {
|
|
239
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
240
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
241
|
+
|
|
242
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
243
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-dev')
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
describe('Force is true', () => {
|
|
247
|
+
it('returns a string', () => {
|
|
248
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
249
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
250
|
+
const MOCK_FORCE = true
|
|
251
|
+
|
|
252
|
+
return expect(getInstallSaveDevSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
253
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-dev')
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
describe('`getInstallSaveOptionalSaveExactCommands()`', () => {
|
|
260
|
+
describe('Always', () => {
|
|
261
|
+
it('returns a string', () => {
|
|
262
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
263
|
+
|
|
264
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES))
|
|
265
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-optional')
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
describe('Registry is defined', () => {
|
|
270
|
+
it('returns a string', () => {
|
|
271
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
272
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
273
|
+
|
|
274
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
275
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-optional')
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
describe('Force is true', () => {
|
|
279
|
+
it('returns a string', () => {
|
|
280
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
281
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
282
|
+
const MOCK_FORCE = true
|
|
283
|
+
|
|
284
|
+
return expect(getInstallSaveOptionalSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
285
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-optional')
|
|
286
|
+
})
|
|
287
|
+
})
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
describe('`getInstallSaveBundleSaveExactCommands()`', () => {
|
|
292
|
+
describe('Always', () => {
|
|
293
|
+
it('returns a string', () => {
|
|
294
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
295
|
+
|
|
296
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES))
|
|
297
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --save-bundle')
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
describe('Registry is defined', () => {
|
|
302
|
+
it('returns a string', () => {
|
|
303
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
304
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
305
|
+
|
|
306
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
307
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --save-bundle')
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
describe('Force is true', () => {
|
|
311
|
+
it('returns a string', () => {
|
|
312
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
313
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
314
|
+
const MOCK_FORCE = true
|
|
315
|
+
|
|
316
|
+
return expect(getInstallSaveBundleSaveExactCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
317
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --save-bundle')
|
|
318
|
+
})
|
|
319
|
+
})
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
describe('`getInstallSaveProdCommands()`', () => {
|
|
324
|
+
describe('Always', () => {
|
|
325
|
+
it('returns a string', () => {
|
|
326
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
327
|
+
|
|
328
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES))
|
|
329
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-prod')
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
describe('Registry is defined', () => {
|
|
334
|
+
it('returns a string', () => {
|
|
335
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
336
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
337
|
+
|
|
338
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
339
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-prod')
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
describe('Force is true', () => {
|
|
343
|
+
it('returns a string', () => {
|
|
344
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
345
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
346
|
+
const MOCK_FORCE = true
|
|
347
|
+
|
|
348
|
+
return expect(getInstallSaveProdCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
349
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-prod')
|
|
350
|
+
})
|
|
351
|
+
})
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
describe('`getInstallSaveDevCommands()`', () => {
|
|
356
|
+
describe('Always', () => {
|
|
357
|
+
it('returns a string', () => {
|
|
358
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
359
|
+
|
|
360
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES))
|
|
361
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-dev')
|
|
362
|
+
})
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
describe('Registry is defined', () => {
|
|
366
|
+
it('returns a string', () => {
|
|
367
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
368
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
369
|
+
|
|
370
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
371
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-dev')
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
describe('Force is true', () => {
|
|
375
|
+
it('returns a string', () => {
|
|
376
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
377
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
378
|
+
const MOCK_FORCE = true
|
|
379
|
+
|
|
380
|
+
return expect(getInstallSaveDevCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
381
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-dev')
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
describe('`getInstallSaveOptionalCommands()`', () => {
|
|
388
|
+
describe('Always', () => {
|
|
389
|
+
it('returns a string', () => {
|
|
390
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
391
|
+
|
|
392
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES))
|
|
393
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-optional')
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
describe('Registry is defined', () => {
|
|
398
|
+
it('returns a string', () => {
|
|
399
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
400
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
401
|
+
|
|
402
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
403
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-optional')
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
describe('Force is true', () => {
|
|
407
|
+
it('returns a string', () => {
|
|
408
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
409
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
410
|
+
const MOCK_FORCE = true
|
|
411
|
+
|
|
412
|
+
return expect(getInstallSaveOptionalCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
413
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-optional')
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
})
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
describe('`getInstallSaveBundleCommands()`', () => {
|
|
420
|
+
describe('Always', () => {
|
|
421
|
+
it('returns a string', () => {
|
|
422
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
423
|
+
|
|
424
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES))
|
|
425
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-bundle')
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
describe('Registry is defined', () => {
|
|
430
|
+
it('returns a string', () => {
|
|
431
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
432
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
433
|
+
|
|
434
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
435
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --save-bundle')
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
describe('Force is true', () => {
|
|
439
|
+
it('returns a string', () => {
|
|
440
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
441
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
442
|
+
const MOCK_FORCE = true
|
|
443
|
+
|
|
444
|
+
return expect(getInstallSaveBundleCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
445
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --save-bundle')
|
|
446
|
+
})
|
|
447
|
+
})
|
|
448
|
+
})
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
describe('`getInstallCommands()`', () => {
|
|
452
|
+
describe('Always', () => {
|
|
453
|
+
it('returns a string', () => {
|
|
454
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
455
|
+
|
|
456
|
+
return expect(getInstallCommands(MOCK_PACKAGES))
|
|
457
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION')
|
|
458
|
+
})
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
describe('Registry is defined', () => {
|
|
462
|
+
it('returns a string', () => {
|
|
463
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
464
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
465
|
+
|
|
466
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_REGISTRY))
|
|
467
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY')
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
describe('Force is true', () => {
|
|
471
|
+
it('returns a string', () => {
|
|
472
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
473
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
474
|
+
const MOCK_FORCE = true
|
|
475
|
+
|
|
476
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_REGISTRY, MOCK_FORCE))
|
|
477
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY')
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
})
|
|
481
|
+
})
|
|
194
482
|
})
|
|
@@ -55,4 +55,158 @@ describe('@modernpoacher/deps/install', () => {
|
|
|
55
55
|
.to.be.a('function')
|
|
56
56
|
})
|
|
57
57
|
})
|
|
58
|
+
|
|
59
|
+
describe('`getInstallSaveExactCommands()`', () => {
|
|
60
|
+
describe('Always', () => {
|
|
61
|
+
it('returns a string', () => {
|
|
62
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
63
|
+
|
|
64
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES))
|
|
65
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --no-save')
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('Save is true', () => {
|
|
70
|
+
it('returns a string', () => {
|
|
71
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
72
|
+
const MOCK_SAVE = true
|
|
73
|
+
|
|
74
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
75
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe('Registry is defined', () => {
|
|
79
|
+
it('returns a string', () => {
|
|
80
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
81
|
+
const MOCK_SAVE = true
|
|
82
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
83
|
+
|
|
84
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
85
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY')
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('Force is true', () => {
|
|
89
|
+
it('returns a string', () => {
|
|
90
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
91
|
+
const MOCK_SAVE = true
|
|
92
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
93
|
+
const MOCK_FORCE = true
|
|
94
|
+
|
|
95
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
96
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY')
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('Save is false', () => {
|
|
103
|
+
it('returns a string', () => {
|
|
104
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
105
|
+
const MOCK_SAVE = false
|
|
106
|
+
|
|
107
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
108
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --no-save')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
describe('Registry is defined', () => {
|
|
112
|
+
it('returns a string', () => {
|
|
113
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
114
|
+
const MOCK_SAVE = false
|
|
115
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
116
|
+
|
|
117
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
118
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --registry REGISTRY --no-save')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
describe('Force is true', () => {
|
|
122
|
+
it('returns a string', () => {
|
|
123
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
124
|
+
const MOCK_SAVE = false
|
|
125
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
126
|
+
const MOCK_FORCE = true
|
|
127
|
+
|
|
128
|
+
return expect(getInstallSaveExactCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
129
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --save-exact --force --registry REGISTRY --no-save')
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
describe('`getInstallCommands()`', () => {
|
|
137
|
+
describe('Always', () => {
|
|
138
|
+
it('returns a string', () => {
|
|
139
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
140
|
+
|
|
141
|
+
return expect(getInstallCommands(MOCK_PACKAGES))
|
|
142
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --no-save')
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
describe('Save is true', () => {
|
|
147
|
+
it('returns a string', () => {
|
|
148
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
149
|
+
const MOCK_SAVE = true
|
|
150
|
+
|
|
151
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
152
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
describe('Registry is defined', () => {
|
|
156
|
+
it('returns a string', () => {
|
|
157
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
158
|
+
const MOCK_SAVE = true
|
|
159
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
160
|
+
|
|
161
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
162
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
describe('Force is true', () => {
|
|
166
|
+
it('returns a string', () => {
|
|
167
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
168
|
+
const MOCK_SAVE = true
|
|
169
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
170
|
+
const MOCK_FORCE = true
|
|
171
|
+
|
|
172
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
173
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY')
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('Save is false', () => {
|
|
180
|
+
it('returns a string', () => {
|
|
181
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
182
|
+
const MOCK_SAVE = false
|
|
183
|
+
|
|
184
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE))
|
|
185
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --no-save')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
describe('Registry is defined', () => {
|
|
189
|
+
it('returns a string', () => {
|
|
190
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
191
|
+
const MOCK_SAVE = false
|
|
192
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
193
|
+
|
|
194
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY))
|
|
195
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --registry REGISTRY --no-save')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
describe('Force is true', () => {
|
|
199
|
+
it('returns a string', () => {
|
|
200
|
+
const MOCK_PACKAGES = { name: 'PACKAGE NAME', version: 'PACKAGE VERSION' }
|
|
201
|
+
const MOCK_SAVE = false
|
|
202
|
+
const MOCK_REGISTRY = 'REGISTRY'
|
|
203
|
+
const MOCK_FORCE = true
|
|
204
|
+
|
|
205
|
+
return expect(getInstallCommands(MOCK_PACKAGES, MOCK_SAVE, MOCK_REGISTRY, MOCK_FORCE))
|
|
206
|
+
.to.equal('npm i PACKAGE NAME@PACKAGE VERSION --force --registry REGISTRY --no-save')
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
})
|
|
58
212
|
})
|