@modernpoacher/deps 2.0.31 → 2.0.32
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/babel.config.cjs +12 -17
- package/bin/common/index.mjs +17 -19
- package/bin/execute/app.mjs +12 -6
- package/package.json +37 -33
- package/src/common/git/index.mjs +73 -50
- package/src/common/index.mjs +37 -0
- package/src/index.mjs +35 -38
- package/src/install/index.mjs +9 -18
package/babel.config.cjs
CHANGED
|
@@ -18,26 +18,21 @@ function env () {
|
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const presets = [
|
|
22
|
-
[
|
|
23
|
-
'@babel/env',
|
|
24
|
-
{
|
|
25
|
-
targets: {
|
|
26
|
-
node: 'current'
|
|
27
|
-
},
|
|
28
|
-
useBuiltIns: 'usage',
|
|
29
|
-
corejs: 3
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
const plugins = []
|
|
35
|
-
|
|
36
21
|
module.exports = (api) => {
|
|
37
22
|
if (api) api.cache.using(env)
|
|
38
23
|
|
|
39
24
|
return {
|
|
40
|
-
presets
|
|
41
|
-
|
|
25
|
+
presets: [
|
|
26
|
+
[
|
|
27
|
+
'@babel/env',
|
|
28
|
+
{
|
|
29
|
+
targets: {
|
|
30
|
+
node: 'current'
|
|
31
|
+
},
|
|
32
|
+
useBuiltIns: 'usage',
|
|
33
|
+
corejs: 3
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
]
|
|
42
37
|
}
|
|
43
38
|
}
|
package/bin/common/index.mjs
CHANGED
|
@@ -34,25 +34,14 @@ import {
|
|
|
34
34
|
getRegistryParameter,
|
|
35
35
|
getForceParameter,
|
|
36
36
|
getExportPath,
|
|
37
|
-
getNvm
|
|
37
|
+
getNvm,
|
|
38
|
+
getOptions
|
|
38
39
|
} from '#deps/src/common'
|
|
39
40
|
|
|
40
41
|
const log = debug('@modernpoacher/deps')
|
|
41
42
|
|
|
42
43
|
log(`\`common\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
43
44
|
|
|
44
|
-
const OPTIONS = {
|
|
45
|
-
maxBuffer: 1024 * 2000,
|
|
46
|
-
stdio: 'inherit',
|
|
47
|
-
env: {
|
|
48
|
-
DEBUG_COLORS: 'yes',
|
|
49
|
-
FORCE_COLOR: PLATFORM === 'win32'
|
|
50
|
-
? 3
|
|
51
|
-
: 2,
|
|
52
|
-
PATH: process.env.PATH
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
45
|
const CODE = 0
|
|
57
46
|
|
|
58
47
|
const MESSAGE = 'Either no error message has been defined or no error has been supplied'
|
|
@@ -229,17 +218,20 @@ async function getConfiguration (directory = DIRECTORY) {
|
|
|
229
218
|
}
|
|
230
219
|
}
|
|
231
220
|
|
|
232
|
-
function rmrf (
|
|
221
|
+
function rmrf (d = DIRECTORY) {
|
|
233
222
|
log('rmrf')
|
|
234
223
|
|
|
224
|
+
const directory = normalize(d.trim())
|
|
225
|
+
|
|
235
226
|
return (
|
|
236
227
|
new Promise((resolve, reject) => {
|
|
237
228
|
const commands = getRmrfCommands()
|
|
229
|
+
const options = getOptions(directory)
|
|
238
230
|
|
|
239
231
|
const {
|
|
240
232
|
stdout,
|
|
241
233
|
stderr
|
|
242
|
-
} = exec(commands,
|
|
234
|
+
} = exec(commands, options, (e, v) => {
|
|
243
235
|
(!e)
|
|
244
236
|
? resolve(v)
|
|
245
237
|
: reject(e)
|
|
@@ -253,17 +245,20 @@ function rmrf (directory = DIRECTORY) {
|
|
|
253
245
|
)
|
|
254
246
|
}
|
|
255
247
|
|
|
256
|
-
function npmi (
|
|
248
|
+
function npmi (d = DIRECTORY, registry = REGISTRY, force = false) {
|
|
257
249
|
log('npmi')
|
|
258
250
|
|
|
251
|
+
const directory = normalize(d.trim())
|
|
252
|
+
|
|
259
253
|
return (
|
|
260
254
|
new Promise((resolve, reject) => {
|
|
261
255
|
const commands = getNpmiCommands(registry, force)
|
|
256
|
+
const options = getOptions(directory)
|
|
262
257
|
|
|
263
258
|
const {
|
|
264
259
|
stdout,
|
|
265
260
|
stderr
|
|
266
|
-
} = exec(commands,
|
|
261
|
+
} = exec(commands, options, (e, v) => {
|
|
267
262
|
(!e)
|
|
268
263
|
? resolve(v)
|
|
269
264
|
: reject(e)
|
|
@@ -277,17 +272,20 @@ function npmi (directory = DIRECTORY, registry = REGISTRY, force = false) {
|
|
|
277
272
|
)
|
|
278
273
|
}
|
|
279
274
|
|
|
280
|
-
function deps (
|
|
275
|
+
function deps (d = DIRECTORY, registry = REGISTRY, force = false) {
|
|
281
276
|
log('deps')
|
|
282
277
|
|
|
278
|
+
const directory = normalize(d.trim())
|
|
279
|
+
|
|
283
280
|
return (
|
|
284
281
|
new Promise((resolve, reject) => {
|
|
285
282
|
const commands = getDepsCommands(registry, force)
|
|
283
|
+
const options = getOptions(directory)
|
|
286
284
|
|
|
287
285
|
const {
|
|
288
286
|
stdout,
|
|
289
287
|
stderr
|
|
290
|
-
} = exec(commands,
|
|
288
|
+
} = exec(commands, options, (e, v) => {
|
|
291
289
|
(!e)
|
|
292
290
|
? resolve(v)
|
|
293
291
|
: reject(e)
|
package/bin/execute/app.mjs
CHANGED
|
@@ -106,7 +106,8 @@ async function isHeadDefaultBranch (directory) {
|
|
|
106
106
|
* Interrogates `.depsrc` or `.depsrc.json` for an `ignore` value
|
|
107
107
|
*
|
|
108
108
|
* @param {string} directory
|
|
109
|
-
*
|
|
109
|
+
*
|
|
110
|
+
* @return {Promise<boolean>}
|
|
110
111
|
*/
|
|
111
112
|
async function getIgnoreFromConfiguration (directory) {
|
|
112
113
|
log('getIgnoreFromConfiguration')
|
|
@@ -128,7 +129,8 @@ async function getIgnoreFromConfiguration (directory) {
|
|
|
128
129
|
* Interrogates `.depsrc` or `.depsrc.json` for an `author` value
|
|
129
130
|
*
|
|
130
131
|
* @param {string} directory
|
|
131
|
-
*
|
|
132
|
+
*
|
|
133
|
+
* @return {Promise<string|null>}
|
|
132
134
|
*/
|
|
133
135
|
async function getAuthorFromConfiguration (directory) {
|
|
134
136
|
log('getAuthorFromConfiguration')
|
|
@@ -150,7 +152,8 @@ async function getAuthorFromConfiguration (directory) {
|
|
|
150
152
|
* Interrogates `package.json` for an `author` value
|
|
151
153
|
*
|
|
152
154
|
* @param {string} directory
|
|
153
|
-
*
|
|
155
|
+
*
|
|
156
|
+
* @return {Promise<string|null>}
|
|
154
157
|
*/
|
|
155
158
|
async function getAuthorFromPackage (directory) {
|
|
156
159
|
log('getAuthorFromPackage')
|
|
@@ -172,7 +175,8 @@ async function getAuthorFromPackage (directory) {
|
|
|
172
175
|
* Interrogates `.depsrc` or `.depsrc.json` for a `message` value
|
|
173
176
|
*
|
|
174
177
|
* @param {string} directory
|
|
175
|
-
*
|
|
178
|
+
*
|
|
179
|
+
* @return {Promise<string|null>}
|
|
176
180
|
*/
|
|
177
181
|
async function getMessageFromConfiguration (directory) {
|
|
178
182
|
log('getMessageFromConfiguration')
|
|
@@ -198,7 +202,8 @@ async function getMessageFromConfiguration (directory) {
|
|
|
198
202
|
*
|
|
199
203
|
* @param {string|null} author
|
|
200
204
|
* @param {string} directory
|
|
201
|
-
*
|
|
205
|
+
*
|
|
206
|
+
* @return {Promise<string>}
|
|
202
207
|
*/
|
|
203
208
|
async function toAuthor (author, directory) {
|
|
204
209
|
return author || await getAuthorFromConfiguration(directory) || await getAuthorFromPackage(directory) || AUTHOR
|
|
@@ -214,7 +219,8 @@ async function toAuthor (author, directory) {
|
|
|
214
219
|
*
|
|
215
220
|
* @param {string|null} message
|
|
216
221
|
* @param {string} directory
|
|
217
|
-
*
|
|
222
|
+
*
|
|
223
|
+
* @return {Promise<string>}
|
|
218
224
|
*/
|
|
219
225
|
async function toMessage (message, directory) {
|
|
220
226
|
return message || await getMessageFromConfiguration(directory) || MESSAGE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernpoacher/deps",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.32",
|
|
4
4
|
"description": "Update NPM package dependencies from the command line",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deps",
|
|
@@ -12,10 +12,14 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "./index.mjs",
|
|
14
14
|
"type": "module",
|
|
15
|
-
"author":
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Jonathan Perry for Modern Poacher Limited",
|
|
17
|
+
"email": "modernpoacher@modernpoacher.com",
|
|
18
|
+
"url": "http://modernpoacher.com"
|
|
19
|
+
},
|
|
16
20
|
"license": "MIT",
|
|
17
21
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
22
|
+
"node": ">=18.12.0"
|
|
19
23
|
},
|
|
20
24
|
"repository": {
|
|
21
25
|
"type": "git",
|
|
@@ -26,58 +30,58 @@
|
|
|
26
30
|
"url": "https://github.com/modernpoacher/deps/issues"
|
|
27
31
|
},
|
|
28
32
|
"scripts": {
|
|
29
|
-
"start": "cross-env DEBUG_COLORS=yes NODE_ENV=production node bin/app.mjs",
|
|
30
|
-
"dev": "cross-env DEBUG_COLORS=yes NODE_ENV=development node bin/app.mjs",
|
|
31
|
-
"dev-install": "cross-env DEBUG_COLORS=yes NODE_ENV=development node bin/install/app.mjs",
|
|
32
|
-
"lint": "eslint . --ext .mjs,.cjs",
|
|
33
|
-
"lint:fix": "npm run lint -- --fix",
|
|
34
|
-
"test": "cross-env DEBUG_COLORS=yes NODE_ENV=test mocha test --recursive -r @babel/register --verbose --color",
|
|
35
33
|
"deps": "cross-env DEBUG_COLORS=yes NODE_ENV=production node bin/app.mjs",
|
|
34
|
+
"deps-deps": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/deps.sh",
|
|
36
35
|
"deps-execute": "cross-env DEBUG_COLORS=yes NODE_ENV=production node bin/execute/app.mjs",
|
|
36
|
+
"deps-head": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/head.sh",
|
|
37
37
|
"deps-install": "cross-env DEBUG_COLORS=yes NODE_ENV=production node bin/install/app.mjs",
|
|
38
|
-
"deps-deps": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/deps.sh",
|
|
39
|
-
"deps-wipe": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/wipe.sh",
|
|
40
38
|
"deps-push": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/push.sh",
|
|
41
|
-
"deps-
|
|
39
|
+
"deps-wipe": "cross-env DEBUG_COLORS=yes NODE_ENV=production bash bin/wipe.sh",
|
|
40
|
+
"dev": "cross-env DEBUG_COLORS=yes NODE_ENV=development node bin/app.mjs",
|
|
41
|
+
"dev-install": "cross-env DEBUG_COLORS=yes NODE_ENV=development node bin/install/app.mjs",
|
|
42
|
+
"lint": "eslint . --ext .mjs,.cjs",
|
|
43
|
+
"lint:fix": "npm run lint -- --fix",
|
|
44
|
+
"start": "cross-env DEBUG_COLORS=yes NODE_ENV=production node bin/app.mjs",
|
|
45
|
+
"test": "cross-env DEBUG_COLORS=yes NODE_ENV=test mocha test --recursive --verbose --color"
|
|
42
46
|
},
|
|
43
47
|
"bin": {
|
|
44
48
|
"deps": "bin/app.mjs",
|
|
49
|
+
"deps-deps": "bin/deps.sh",
|
|
45
50
|
"deps-execute": "bin/execute/app.mjs",
|
|
51
|
+
"deps-head": "bin/head.sh",
|
|
46
52
|
"deps-install": "bin/install/app.mjs",
|
|
47
|
-
"deps-deps": "bin/deps.sh",
|
|
48
|
-
"deps-wipe": "bin/wipe.sh",
|
|
49
53
|
"deps-push": "bin/push.sh",
|
|
50
|
-
"deps-
|
|
54
|
+
"deps-wipe": "bin/wipe.sh"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"commander": "^
|
|
54
|
-
"debug": "^4.3.
|
|
57
|
+
"commander": "^12.1.0",
|
|
58
|
+
"debug": "^4.3.5",
|
|
55
59
|
"glob-all": "^3.3.1",
|
|
56
60
|
"supports-color": "^9.4.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/eslint-parser": "^7.
|
|
61
|
-
"@babel/preset-env": "^7.
|
|
62
|
-
"@babel/register": "^7.
|
|
63
|
-
"chai": "^
|
|
64
|
-
"core-js": "^3.
|
|
63
|
+
"@babel/core": "^7.24.7",
|
|
64
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
65
|
+
"@babel/preset-env": "^7.24.7",
|
|
66
|
+
"@babel/register": "^7.24.6",
|
|
67
|
+
"chai": "^5.1.1",
|
|
68
|
+
"core-js": "^3.37.1",
|
|
65
69
|
"cross-env": "^7.0.3",
|
|
66
|
-
"eslint": "
|
|
70
|
+
"eslint": "8.57.0",
|
|
67
71
|
"eslint-config-standard": "^17.1.0",
|
|
68
|
-
"husky": "^
|
|
69
|
-
"mocha": "^10.2
|
|
72
|
+
"husky": "^9.0.11",
|
|
73
|
+
"mocha": "^10.5.2"
|
|
70
74
|
},
|
|
71
75
|
"imports": {
|
|
72
|
-
"#
|
|
76
|
+
"#deps/bin": "./bin/index.mjs",
|
|
77
|
+
"#deps/bin/*": "./bin/*.mjs",
|
|
78
|
+
"#deps/bin/common": "./bin/common/index.mjs",
|
|
79
|
+
"#deps/src": "./src/index.mjs",
|
|
80
|
+
"#deps/src/*": "./src/*.mjs",
|
|
81
|
+
"#deps/src/common": "./src/common/index.mjs",
|
|
73
82
|
"#deps/src/common/env": "./src/common/env/index.mjs",
|
|
74
83
|
"#deps/src/common/git": "./src/common/git/index.mjs",
|
|
75
|
-
"#deps/src/common": "./src/common/index.mjs",
|
|
76
84
|
"#deps/src/install": "./src/install/index.mjs",
|
|
77
|
-
"#
|
|
78
|
-
"#deps/src": "./src/index.mjs",
|
|
79
|
-
"#deps/bin/common": "./bin/common/index.mjs",
|
|
80
|
-
"#deps/bin/*": "./bin/*.mjs",
|
|
81
|
-
"#deps/bin": "./bin/index.mjs"
|
|
85
|
+
"#where-am-i": "./where-am-i.mjs"
|
|
82
86
|
}
|
|
83
87
|
}
|
package/src/common/git/index.mjs
CHANGED
|
@@ -13,6 +13,10 @@ import {
|
|
|
13
13
|
PLATFORM
|
|
14
14
|
} from '#deps/src/common/env'
|
|
15
15
|
|
|
16
|
+
import {
|
|
17
|
+
getOptions
|
|
18
|
+
} from '#deps/src/common'
|
|
19
|
+
|
|
16
20
|
export const DIRECTORY = '.'
|
|
17
21
|
|
|
18
22
|
const BRANCH = 'master'
|
|
@@ -49,18 +53,6 @@ git push --tags
|
|
|
49
53
|
eval $(ssh-agent -k) 1> /dev/null
|
|
50
54
|
`
|
|
51
55
|
|
|
52
|
-
const OPTIONS = {
|
|
53
|
-
maxBuffer: 1024 * 2000,
|
|
54
|
-
stdio: 'inherit',
|
|
55
|
-
env: {
|
|
56
|
-
DEBUG_COLORS: 'yes',
|
|
57
|
-
FORCE_COLOR: PLATFORM === 'win32'
|
|
58
|
-
? 3
|
|
59
|
-
: 2,
|
|
60
|
-
PATH: process.env.PATH
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
56
|
const log = debug('@modernpoacher/deps')
|
|
65
57
|
|
|
66
58
|
log(`\`git\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
@@ -152,28 +144,31 @@ function isCommandError (e) {
|
|
|
152
144
|
*
|
|
153
145
|
* Get the default branch from `.git/refs/remotes/origin/HEAD`
|
|
154
146
|
*
|
|
155
|
-
* @param {string}
|
|
147
|
+
* @param {string} d - A directory configured for Git
|
|
156
148
|
*
|
|
157
149
|
* @return {Promise<string>}
|
|
158
150
|
*/
|
|
159
|
-
export function catGitRefsRemotesOriginHead (
|
|
151
|
+
export function catGitRefsRemotesOriginHead (d = DIRECTORY) {
|
|
160
152
|
log('catGitRefsRemotesOriginHead')
|
|
161
153
|
|
|
154
|
+
const directory = normalize(d.trim())
|
|
155
|
+
|
|
162
156
|
return (
|
|
163
157
|
new Promise((resolve, reject) => {
|
|
164
158
|
const commands = CAT_GIT_REFS_REMOTES_ORIGIN_HEAD.trim()
|
|
159
|
+
const options = getOptions(directory)
|
|
165
160
|
|
|
166
161
|
const {
|
|
167
162
|
stdout,
|
|
168
163
|
stderr
|
|
169
|
-
} = exec(commands,
|
|
164
|
+
} = exec(commands, options, (e, v = '') => {
|
|
170
165
|
(!e)
|
|
171
166
|
? resolve(trim(v))
|
|
172
167
|
: reject(e)
|
|
173
168
|
})
|
|
174
169
|
|
|
175
|
-
stdout.on('data', out('cat-git-refs-remotes-origin-head', directory
|
|
176
|
-
stderr.on('data', err('cat-git-refs-remotes-origin-head', directory
|
|
170
|
+
stdout.on('data', out('cat-git-refs-remotes-origin-head', directory))
|
|
171
|
+
stderr.on('data', err('cat-git-refs-remotes-origin-head', directory))
|
|
177
172
|
})
|
|
178
173
|
)
|
|
179
174
|
}
|
|
@@ -183,28 +178,31 @@ export function catGitRefsRemotesOriginHead (directory = DIRECTORY) {
|
|
|
183
178
|
*
|
|
184
179
|
* Get the remote default branch
|
|
185
180
|
*
|
|
186
|
-
* @param {string}
|
|
181
|
+
* @param {string} d - A directory configured for Git
|
|
187
182
|
*
|
|
188
183
|
* @return {Promise<string>}
|
|
189
184
|
*/
|
|
190
|
-
export function awkGitRemoteShowOriginHead (
|
|
185
|
+
export function awkGitRemoteShowOriginHead (d = DIRECTORY) {
|
|
191
186
|
log('awkGitRemoteShowOriginHead')
|
|
192
187
|
|
|
188
|
+
const directory = normalize(d.trim())
|
|
189
|
+
|
|
193
190
|
return (
|
|
194
191
|
new Promise((resolve, reject) => {
|
|
195
192
|
const command = 'git remote show origin | awk \'/HEAD branch/ {print $NF}\''
|
|
193
|
+
const options = getOptions(directory)
|
|
196
194
|
|
|
197
195
|
const {
|
|
198
196
|
stdout,
|
|
199
197
|
stderr
|
|
200
|
-
} = exec(command,
|
|
198
|
+
} = exec(command, options, (e, v = '') => {
|
|
201
199
|
(!e)
|
|
202
200
|
? resolve(trim(v))
|
|
203
201
|
: reject(e)
|
|
204
202
|
})
|
|
205
203
|
|
|
206
|
-
stdout.on('data', out('git-remote-show-origin-head', directory
|
|
207
|
-
stderr.on('data', err('git-remote-show-origin-head', directory
|
|
204
|
+
stdout.on('data', out('git-remote-show-origin-head', directory))
|
|
205
|
+
stderr.on('data', err('git-remote-show-origin-head', directory))
|
|
208
206
|
})
|
|
209
207
|
)
|
|
210
208
|
}
|
|
@@ -214,28 +212,31 @@ export function awkGitRemoteShowOriginHead (directory = DIRECTORY) {
|
|
|
214
212
|
*
|
|
215
213
|
* Determine whether a directory is configured for Git
|
|
216
214
|
*
|
|
217
|
-
* @param {string}
|
|
215
|
+
* @param {string} d - A directory
|
|
218
216
|
*
|
|
219
217
|
* @return {Promise<string>}
|
|
220
218
|
*/
|
|
221
|
-
export function gitRevParseShowTopLevel (
|
|
219
|
+
export function gitRevParseShowTopLevel (d = DIRECTORY) {
|
|
222
220
|
log('gitRevParseShowTopLevel')
|
|
223
221
|
|
|
222
|
+
const directory = normalize(d.trim())
|
|
223
|
+
|
|
224
224
|
return (
|
|
225
225
|
new Promise((resolve, reject) => {
|
|
226
226
|
const commands = 'git rev-parse --show-toplevel'
|
|
227
|
+
const options = getOptions(directory)
|
|
227
228
|
|
|
228
229
|
const {
|
|
229
230
|
stdout,
|
|
230
231
|
stderr
|
|
231
|
-
} = exec(commands,
|
|
232
|
+
} = exec(commands, options, (e, v = '') => {
|
|
232
233
|
(!e)
|
|
233
234
|
? resolve(trim(v))
|
|
234
235
|
: reject(e)
|
|
235
236
|
})
|
|
236
237
|
|
|
237
|
-
stdout.on('data', out('git-rev-parse-show-toplevel', directory
|
|
238
|
-
stderr.on('data', err('git-rev-parse-show-toplevel', directory
|
|
238
|
+
stdout.on('data', out('git-rev-parse-show-toplevel', directory))
|
|
239
|
+
stderr.on('data', err('git-rev-parse-show-toplevel', directory))
|
|
239
240
|
})
|
|
240
241
|
)
|
|
241
242
|
}
|
|
@@ -245,28 +246,31 @@ export function gitRevParseShowTopLevel (directory = DIRECTORY) {
|
|
|
245
246
|
*
|
|
246
247
|
* Determine which branch is HEAD
|
|
247
248
|
*
|
|
248
|
-
* @param {string}
|
|
249
|
+
* @param {string} d - A directory
|
|
249
250
|
*
|
|
250
251
|
* @return {Promise<string>}
|
|
251
252
|
*/
|
|
252
|
-
export function gitRevParseAbbrevRefHead (
|
|
253
|
+
export function gitRevParseAbbrevRefHead (d = DIRECTORY) {
|
|
253
254
|
log('gitRevParseAbbrevRefHead')
|
|
254
255
|
|
|
256
|
+
const directory = normalize(d.trim())
|
|
257
|
+
|
|
255
258
|
return (
|
|
256
259
|
new Promise((resolve, reject) => {
|
|
257
260
|
const command = 'git rev-parse --abbrev-ref HEAD'
|
|
261
|
+
const options = getOptions(directory)
|
|
258
262
|
|
|
259
263
|
const {
|
|
260
264
|
stdout,
|
|
261
265
|
stderr
|
|
262
|
-
} = exec(command,
|
|
266
|
+
} = exec(command, options, (e, v = '') => {
|
|
263
267
|
(!e)
|
|
264
268
|
? resolve(trim(v))
|
|
265
269
|
: reject(e)
|
|
266
270
|
})
|
|
267
271
|
|
|
268
|
-
stdout.on('data', out('git-rev-parse-abbrev-ref-head', directory
|
|
269
|
-
stderr.on('data', err('git-rev-parse-abbrev-ref-head', directory
|
|
272
|
+
stdout.on('data', out('git-rev-parse-abbrev-ref-head', directory))
|
|
273
|
+
stderr.on('data', err('git-rev-parse-abbrev-ref-head', directory))
|
|
270
274
|
})
|
|
271
275
|
)
|
|
272
276
|
}
|
|
@@ -276,22 +280,25 @@ export function gitRevParseAbbrevRefHead (directory = DIRECTORY) {
|
|
|
276
280
|
*
|
|
277
281
|
* Switch to the default value if none is supplied
|
|
278
282
|
*
|
|
279
|
-
* @param {string}
|
|
283
|
+
* @param {string} d - A directory configured for Git
|
|
280
284
|
* @param {string} branch - The Git branch
|
|
281
285
|
*
|
|
282
286
|
* @return {Promise<string>}
|
|
283
287
|
*/
|
|
284
|
-
export function gitCheckout (
|
|
288
|
+
export function gitCheckout (d = DIRECTORY, branch = BRANCH) {
|
|
285
289
|
log('gitCheckout')
|
|
286
290
|
|
|
291
|
+
const directory = normalize(d.trim())
|
|
292
|
+
|
|
287
293
|
return (
|
|
288
294
|
new Promise((resolve, reject) => {
|
|
289
295
|
const commands = `git checkout ${branch}`
|
|
296
|
+
const options = getOptions(directory)
|
|
290
297
|
|
|
291
298
|
const {
|
|
292
299
|
stdout,
|
|
293
300
|
stderr
|
|
294
|
-
} = exec(commands,
|
|
301
|
+
} = exec(commands, options, (e, v) => {
|
|
295
302
|
(!e)
|
|
296
303
|
? resolve(v)
|
|
297
304
|
: isCommandError(e)
|
|
@@ -312,21 +319,24 @@ export function gitCheckout (directory = DIRECTORY, branch = BRANCH) {
|
|
|
312
319
|
*
|
|
313
320
|
* Pull changes from the Git remote
|
|
314
321
|
*
|
|
315
|
-
* @param {string}
|
|
322
|
+
* @param {string} d - A directory configured for Git
|
|
316
323
|
*
|
|
317
324
|
* @return {Promise<string>}
|
|
318
325
|
*/
|
|
319
|
-
export function gitPull (
|
|
326
|
+
export function gitPull (d = DIRECTORY) {
|
|
320
327
|
log('gitPull')
|
|
321
328
|
|
|
329
|
+
const directory = normalize(d.trim())
|
|
330
|
+
|
|
322
331
|
return (
|
|
323
332
|
new Promise((resolve, reject) => {
|
|
324
333
|
const commands = GIT_PULL.trim()
|
|
334
|
+
const options = getOptions(directory)
|
|
325
335
|
|
|
326
336
|
const {
|
|
327
337
|
stdout,
|
|
328
338
|
stderr
|
|
329
|
-
} = exec(commands,
|
|
339
|
+
} = exec(commands, options, (e, v) => {
|
|
330
340
|
(!e)
|
|
331
341
|
? resolve(v)
|
|
332
342
|
: isCommandError(e)
|
|
@@ -347,21 +357,24 @@ export function gitPull (directory = DIRECTORY) {
|
|
|
347
357
|
*
|
|
348
358
|
* Push changes to the Git remote
|
|
349
359
|
*
|
|
350
|
-
* @param {string}
|
|
360
|
+
* @param {string} d - A directory configured for Git
|
|
351
361
|
*
|
|
352
362
|
* @return {Promise<string>}
|
|
353
363
|
*/
|
|
354
|
-
export function gitPush (
|
|
364
|
+
export function gitPush (d = DIRECTORY) {
|
|
355
365
|
log('gitPush')
|
|
356
366
|
|
|
367
|
+
const directory = normalize(d.trim())
|
|
368
|
+
|
|
357
369
|
return (
|
|
358
370
|
new Promise((resolve, reject) => {
|
|
359
371
|
const commands = GIT_PUSH.trim()
|
|
372
|
+
const options = getOptions(directory)
|
|
360
373
|
|
|
361
374
|
const {
|
|
362
375
|
stdout,
|
|
363
376
|
stderr
|
|
364
|
-
} = exec(commands,
|
|
377
|
+
} = exec(commands, options, (e, v) => {
|
|
365
378
|
(!e)
|
|
366
379
|
? resolve(v)
|
|
367
380
|
: isCommandError(e)
|
|
@@ -382,21 +395,24 @@ export function gitPush (directory = DIRECTORY) {
|
|
|
382
395
|
*
|
|
383
396
|
* Push tags changes to the Git remote
|
|
384
397
|
*
|
|
385
|
-
* @param {string}
|
|
398
|
+
* @param {string} d - A directory configured for Git
|
|
386
399
|
*
|
|
387
400
|
* @return {Promise<string>}
|
|
388
401
|
*/
|
|
389
|
-
export function gitPushTags (
|
|
402
|
+
export function gitPushTags (d = DIRECTORY) {
|
|
390
403
|
log('gitPushTags')
|
|
391
404
|
|
|
405
|
+
const directory = normalize(d.trim())
|
|
406
|
+
|
|
392
407
|
return (
|
|
393
408
|
new Promise((resolve, reject) => {
|
|
394
409
|
const commands = GIT_PUSH_TAGS.trim()
|
|
410
|
+
const options = getOptions(directory)
|
|
395
411
|
|
|
396
412
|
const {
|
|
397
413
|
stdout,
|
|
398
414
|
stderr
|
|
399
|
-
} = exec(commands,
|
|
415
|
+
} = exec(commands, options, (e, v) => {
|
|
400
416
|
(!e)
|
|
401
417
|
? resolve(v)
|
|
402
418
|
: isCommandError(e)
|
|
@@ -417,22 +433,25 @@ export function gitPushTags (directory = DIRECTORY) {
|
|
|
417
433
|
*
|
|
418
434
|
* Add changes to Git with a default value if none is supplied
|
|
419
435
|
*
|
|
420
|
-
* @param {string}
|
|
436
|
+
* @param {string} d - A directory configured for Git
|
|
421
437
|
* @param {string} add - An add parameter
|
|
422
438
|
*
|
|
423
439
|
* @return {Promise<string>}
|
|
424
440
|
*/
|
|
425
|
-
export function gitAdd (
|
|
441
|
+
export function gitAdd (d = DIRECTORY, add = ADD) {
|
|
426
442
|
log('gitAdd')
|
|
427
443
|
|
|
444
|
+
const directory = normalize(d.trim())
|
|
445
|
+
|
|
428
446
|
return (
|
|
429
447
|
new Promise((resolve, reject) => {
|
|
430
448
|
const commands = `git add ${add}`
|
|
449
|
+
const options = getOptions(directory)
|
|
431
450
|
|
|
432
451
|
const {
|
|
433
452
|
stdout,
|
|
434
453
|
stderr
|
|
435
|
-
} = exec(commands,
|
|
454
|
+
} = exec(commands, options, (e, v) => {
|
|
436
455
|
(!e)
|
|
437
456
|
? resolve(v)
|
|
438
457
|
: isCommandError(e)
|
|
@@ -453,22 +472,26 @@ export function gitAdd (directory = DIRECTORY, add = ADD) {
|
|
|
453
472
|
*
|
|
454
473
|
* Commit changes to Git with a default value if none is supplied
|
|
455
474
|
*
|
|
456
|
-
* @param {string}
|
|
475
|
+
* @param {string} c - A directory configured for Git
|
|
457
476
|
* @param {string} message - A commit message
|
|
477
|
+
* @param {string} author - The commit author
|
|
458
478
|
*
|
|
459
479
|
* @return {Promise<string>}
|
|
460
480
|
*/
|
|
461
|
-
export function gitCommit (
|
|
481
|
+
export function gitCommit (d = DIRECTORY, message = MESSAGE, author = AUTHOR) {
|
|
462
482
|
log('gitCommit')
|
|
463
483
|
|
|
484
|
+
const directory = normalize(d.trim())
|
|
485
|
+
|
|
464
486
|
return (
|
|
465
487
|
new Promise((resolve, reject) => {
|
|
466
488
|
const commands = `git commit -m "${message}" --author "${author}"`
|
|
489
|
+
const options = getOptions(directory)
|
|
467
490
|
|
|
468
491
|
const {
|
|
469
492
|
stdout,
|
|
470
493
|
stderr
|
|
471
|
-
} = exec(commands,
|
|
494
|
+
} = exec(commands, options, (e, v) => {
|
|
472
495
|
(!e)
|
|
473
496
|
? resolve(v)
|
|
474
497
|
: isCommandError(e)
|
package/src/common/index.mjs
CHANGED
|
@@ -54,6 +54,18 @@ export const AUTHOR = 'Modern Poacher Limited <modernpoacher@modernpoacher.com>'
|
|
|
54
54
|
|
|
55
55
|
export const NVM = resolve(PATH, 'nvm.sh')
|
|
56
56
|
|
|
57
|
+
export const OPTIONS = {
|
|
58
|
+
maxBuffer: 1024 * 2000,
|
|
59
|
+
stdio: 'inherit',
|
|
60
|
+
env: {
|
|
61
|
+
DEBUG_COLORS: 'yes',
|
|
62
|
+
FORCE_COLOR: PLATFORM === 'win32'
|
|
63
|
+
? 3
|
|
64
|
+
: 2,
|
|
65
|
+
PATH: process.env.PATH
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
const log = debug('@modernpoacher/deps')
|
|
58
70
|
|
|
59
71
|
log(`\`common\` (${VERSION} - ${PLATFORM}) is awake at "${PATH}"`)
|
|
@@ -192,6 +204,31 @@ export const getCommands = PLATFORM === 'win32'
|
|
|
192
204
|
? (commands = 'npm i') => tidy(commands)
|
|
193
205
|
: (commands = 'npm i') => tidy(getExportPath(getNvm(commands)))
|
|
194
206
|
|
|
207
|
+
/**
|
|
208
|
+
* @function getOptions
|
|
209
|
+
*
|
|
210
|
+
* Get the installation `exec` child process options
|
|
211
|
+
*
|
|
212
|
+
* @param {string} cwd normalized directory
|
|
213
|
+
*
|
|
214
|
+
* @return {{
|
|
215
|
+
* maxBuffer: number,
|
|
216
|
+
* stdio: string
|
|
217
|
+
* env: {
|
|
218
|
+
* DEBUG_COLORS: string,
|
|
219
|
+
* FORCE_COLOR: number,
|
|
220
|
+
* PROCESS: string
|
|
221
|
+
* }
|
|
222
|
+
* cwd: string
|
|
223
|
+
* }}
|
|
224
|
+
*/
|
|
225
|
+
export function getOptions (cwd) {
|
|
226
|
+
return {
|
|
227
|
+
...OPTIONS,
|
|
228
|
+
cwd
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
195
232
|
/**
|
|
196
233
|
* @function getProdDependencies
|
|
197
234
|
*
|
package/src/index.mjs
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
getSaveDevParameter,
|
|
35
35
|
getSaveProdParameter,
|
|
36
36
|
getCommands,
|
|
37
|
+
getOptions,
|
|
37
38
|
normalizeCommands,
|
|
38
39
|
transform,
|
|
39
40
|
getDepsExact,
|
|
@@ -44,18 +45,6 @@ const log = debug('@modernpoacher/deps')
|
|
|
44
45
|
|
|
45
46
|
log(`\`deps\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
46
47
|
|
|
47
|
-
const OPTIONS = {
|
|
48
|
-
maxBuffer: 1024 * 2000,
|
|
49
|
-
stdio: 'inherit',
|
|
50
|
-
env: {
|
|
51
|
-
DEBUG_COLORS: 'yes',
|
|
52
|
-
FORCE_COLOR: PLATFORM === 'win32'
|
|
53
|
-
? 3
|
|
54
|
-
: 2,
|
|
55
|
-
PATH: process.env.PATH
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
48
|
function use (key) {
|
|
60
49
|
const log = debug(`@modernpoacher/deps:${key}`)
|
|
61
50
|
|
|
@@ -73,7 +62,7 @@ function use (key) {
|
|
|
73
62
|
/**
|
|
74
63
|
* @function getInstallSaveExactCommands
|
|
75
64
|
*
|
|
76
|
-
* Get the `npm install --save-exact` commands as a string
|
|
65
|
+
* Get the `npm install --save-exact` commands as a string
|
|
77
66
|
*
|
|
78
67
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
79
68
|
* @param {string} r - Registry
|
|
@@ -95,7 +84,7 @@ export function getInstallSaveExactCommands (deps, r, f) {
|
|
|
95
84
|
/**
|
|
96
85
|
* @function getInstallCommands
|
|
97
86
|
*
|
|
98
|
-
* Get the `npm install` commands as a string
|
|
87
|
+
* Get the `npm install` commands as a string
|
|
99
88
|
*
|
|
100
89
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
101
90
|
* @param {string} r - Registry
|
|
@@ -117,7 +106,7 @@ export function getInstallCommands (deps, r, f) {
|
|
|
117
106
|
/**
|
|
118
107
|
* @function getInstallSaveBundleSaveExactCommands
|
|
119
108
|
*
|
|
120
|
-
* Get the `npm install --save-bundle --save-exact` commands as a string
|
|
109
|
+
* Get the `npm install --save-bundle --save-exact` commands as a string
|
|
121
110
|
*
|
|
122
111
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
123
112
|
* @param {string} r - Registry
|
|
@@ -138,7 +127,7 @@ export function getInstallSaveBundleSaveExactCommands (deps, r, f) {
|
|
|
138
127
|
/**
|
|
139
128
|
* @function getInstallSaveBundleCommands
|
|
140
129
|
*
|
|
141
|
-
* Get the `npm install --save-bundle` commands as a string
|
|
130
|
+
* Get the `npm install --save-bundle` commands as a string
|
|
142
131
|
*
|
|
143
132
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
144
133
|
* @param {string} r - Registry
|
|
@@ -159,7 +148,7 @@ export function getInstallSaveBundleCommands (deps, r, f) {
|
|
|
159
148
|
/**
|
|
160
149
|
* @function getInstallSaveOptionalSaveExactCommands
|
|
161
150
|
*
|
|
162
|
-
* Get the `npm install --save-optional --save-exact` commands as a string
|
|
151
|
+
* Get the `npm install --save-optional --save-exact` commands as a string
|
|
163
152
|
*
|
|
164
153
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
165
154
|
* @param {string} r - Registry
|
|
@@ -180,7 +169,7 @@ export function getInstallSaveOptionalSaveExactCommands (deps, r, f) {
|
|
|
180
169
|
/**
|
|
181
170
|
* @function getInstallSaveOptionalCommands
|
|
182
171
|
*
|
|
183
|
-
* Get the `npm install --save-optional` commands as a string
|
|
172
|
+
* Get the `npm install --save-optional` commands as a string
|
|
184
173
|
*
|
|
185
174
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
186
175
|
* @param {string} r - Registry
|
|
@@ -201,7 +190,7 @@ export function getInstallSaveOptionalCommands (deps, r, f) {
|
|
|
201
190
|
/**
|
|
202
191
|
* @function getInstallSaveDevSaveExactCommands
|
|
203
192
|
*
|
|
204
|
-
* Get the `npm install --save-dev --save-exact` commands as a string
|
|
193
|
+
* Get the `npm install --save-dev --save-exact` commands as a string
|
|
205
194
|
*
|
|
206
195
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
207
196
|
* @param {string} r - Registry
|
|
@@ -222,7 +211,7 @@ export function getInstallSaveDevSaveExactCommands (deps, r, f) {
|
|
|
222
211
|
/**
|
|
223
212
|
* @function getInstallSaveDevCommands
|
|
224
213
|
*
|
|
225
|
-
* Get the `npm install --save-dev` commands as a string
|
|
214
|
+
* Get the `npm install --save-dev` commands as a string
|
|
226
215
|
*
|
|
227
216
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
228
217
|
* @param {string} r - Registry
|
|
@@ -243,7 +232,7 @@ export function getInstallSaveDevCommands (deps, r, f) {
|
|
|
243
232
|
/**
|
|
244
233
|
* @function getInstallSaveProdSaveExactCommands
|
|
245
234
|
*
|
|
246
|
-
* Get the `npm install --save-prod --save-exact` commands as a string
|
|
235
|
+
* Get the `npm install --save-prod --save-exact` commands as a string
|
|
247
236
|
*
|
|
248
237
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
249
238
|
* @param {string} r - Registry
|
|
@@ -264,7 +253,7 @@ export function getInstallSaveProdSaveExactCommands (deps, r, f) {
|
|
|
264
253
|
/**
|
|
265
254
|
* @function getInstallSaveProdCommands
|
|
266
255
|
*
|
|
267
|
-
* Get the `npm install --save-prod` commands as a string
|
|
256
|
+
* Get the `npm install --save-prod` commands as a string
|
|
268
257
|
*
|
|
269
258
|
* @param {DependencyDescriptor|DependencyDescriptor[]} deps - Dependency descriptor(s)
|
|
270
259
|
* @param {string} r - Registry
|
|
@@ -297,18 +286,19 @@ export function getInstallSaveProdCommands (deps, r, f) {
|
|
|
297
286
|
export function installSaveBundleSaveExact (d, deps, r, f) {
|
|
298
287
|
log('installSaveBundleSaveExact')
|
|
299
288
|
|
|
300
|
-
const directory = normalize(d)
|
|
289
|
+
const directory = normalize(d.trim())
|
|
301
290
|
|
|
302
291
|
log(`Directory is "${directory}"`)
|
|
303
292
|
|
|
304
293
|
return (
|
|
305
294
|
new Promise((resolve, reject) => {
|
|
306
295
|
const commands = getCommands(getInstallSaveBundleSaveExactCommands(deps, r, f))
|
|
296
|
+
const options = getOptions(directory)
|
|
307
297
|
|
|
308
298
|
const {
|
|
309
299
|
stdout,
|
|
310
300
|
stderr
|
|
311
|
-
} = exec(commands,
|
|
301
|
+
} = exec(commands, options, (e, v) => {
|
|
312
302
|
(!e)
|
|
313
303
|
? resolve(v)
|
|
314
304
|
: reject(e)
|
|
@@ -337,18 +327,19 @@ export function installSaveBundleSaveExact (d, deps, r, f) {
|
|
|
337
327
|
export function installSaveBundle (d, deps, r, f) {
|
|
338
328
|
log('installSaveBundle')
|
|
339
329
|
|
|
340
|
-
const directory = normalize(d)
|
|
330
|
+
const directory = normalize(d.trim())
|
|
341
331
|
|
|
342
332
|
log(`Directory is "${directory}"`)
|
|
343
333
|
|
|
344
334
|
return (
|
|
345
335
|
new Promise((resolve, reject) => {
|
|
346
336
|
const commands = getCommands(getInstallSaveBundleCommands(deps, r, f))
|
|
337
|
+
const options = getOptions(directory)
|
|
347
338
|
|
|
348
339
|
const {
|
|
349
340
|
stdout,
|
|
350
341
|
stderr
|
|
351
|
-
} = exec(commands,
|
|
342
|
+
} = exec(commands, options, (e, v) => {
|
|
352
343
|
(!e)
|
|
353
344
|
? resolve(v)
|
|
354
345
|
: reject(e)
|
|
@@ -377,18 +368,19 @@ export function installSaveBundle (d, deps, r, f) {
|
|
|
377
368
|
export function installSaveOptionalSaveExact (d, deps, r, f) {
|
|
378
369
|
log('installSaveOptionalSaveExact')
|
|
379
370
|
|
|
380
|
-
const directory = normalize(d)
|
|
371
|
+
const directory = normalize(d.trim())
|
|
381
372
|
|
|
382
373
|
log(`Directory is "${directory}"`)
|
|
383
374
|
|
|
384
375
|
return (
|
|
385
376
|
new Promise((resolve, reject) => {
|
|
386
377
|
const commands = getCommands(getInstallSaveOptionalSaveExactCommands(deps, r, f))
|
|
378
|
+
const options = getOptions(directory)
|
|
387
379
|
|
|
388
380
|
const {
|
|
389
381
|
stdout,
|
|
390
382
|
stderr
|
|
391
|
-
} = exec(commands,
|
|
383
|
+
} = exec(commands, options, (e, v) => {
|
|
392
384
|
(!e)
|
|
393
385
|
? resolve(v)
|
|
394
386
|
: reject(e)
|
|
@@ -417,18 +409,19 @@ export function installSaveOptionalSaveExact (d, deps, r, f) {
|
|
|
417
409
|
export function installSaveOptional (d, dependencies, r, f) {
|
|
418
410
|
log('installSaveOptional')
|
|
419
411
|
|
|
420
|
-
const directory = normalize(d)
|
|
412
|
+
const directory = normalize(d.trim())
|
|
421
413
|
|
|
422
414
|
log(`Directory is "${directory}"`)
|
|
423
415
|
|
|
424
416
|
return (
|
|
425
417
|
new Promise((resolve, reject) => {
|
|
426
418
|
const commands = getCommands(getInstallSaveOptionalCommands(dependencies, r, f))
|
|
419
|
+
const options = getOptions(directory)
|
|
427
420
|
|
|
428
421
|
const {
|
|
429
422
|
stdout,
|
|
430
423
|
stderr
|
|
431
|
-
} = exec(commands,
|
|
424
|
+
} = exec(commands, options, (e, v) => {
|
|
432
425
|
(!e)
|
|
433
426
|
? resolve(v)
|
|
434
427
|
: reject(e)
|
|
@@ -457,18 +450,19 @@ export function installSaveOptional (d, dependencies, r, f) {
|
|
|
457
450
|
export function installSaveDevSaveExact (d, deps, r, f) {
|
|
458
451
|
log('installSaveDevSaveExact')
|
|
459
452
|
|
|
460
|
-
const directory = normalize(d)
|
|
453
|
+
const directory = normalize(d.trim())
|
|
461
454
|
|
|
462
455
|
log(`Directory is "${directory}"`)
|
|
463
456
|
|
|
464
457
|
return (
|
|
465
458
|
new Promise((resolve, reject) => {
|
|
466
459
|
const commands = getCommands(getInstallSaveDevSaveExactCommands(deps, r, f))
|
|
460
|
+
const options = getOptions(directory)
|
|
467
461
|
|
|
468
462
|
const {
|
|
469
463
|
stdout,
|
|
470
464
|
stderr
|
|
471
|
-
} = exec(commands,
|
|
465
|
+
} = exec(commands, options, (e, v) => {
|
|
472
466
|
(!e)
|
|
473
467
|
? resolve(v)
|
|
474
468
|
: reject(e)
|
|
@@ -497,18 +491,19 @@ export function installSaveDevSaveExact (d, deps, r, f) {
|
|
|
497
491
|
export function installSaveDev (d, deps, r, f) {
|
|
498
492
|
log('installSaveDev')
|
|
499
493
|
|
|
500
|
-
const directory = normalize(d)
|
|
494
|
+
const directory = normalize(d.trim())
|
|
501
495
|
|
|
502
496
|
log(`Directory is "${directory}"`)
|
|
503
497
|
|
|
504
498
|
return (
|
|
505
499
|
new Promise((resolve, reject) => {
|
|
506
500
|
const commands = getCommands(getInstallSaveDevCommands(deps, r, f))
|
|
501
|
+
const options = getOptions(directory)
|
|
507
502
|
|
|
508
503
|
const {
|
|
509
504
|
stdout,
|
|
510
505
|
stderr
|
|
511
|
-
} = exec(commands,
|
|
506
|
+
} = exec(commands, options, (e, v) => {
|
|
512
507
|
(!e)
|
|
513
508
|
? resolve(v)
|
|
514
509
|
: reject(e)
|
|
@@ -537,18 +532,19 @@ export function installSaveDev (d, deps, r, f) {
|
|
|
537
532
|
export function installSaveProdSaveExact (d, deps, r, f) {
|
|
538
533
|
log('installSaveProdSaveExact')
|
|
539
534
|
|
|
540
|
-
const directory = normalize(d)
|
|
535
|
+
const directory = normalize(d.trim())
|
|
541
536
|
|
|
542
537
|
log(`Directory is "${directory}"`)
|
|
543
538
|
|
|
544
539
|
return (
|
|
545
540
|
new Promise((resolve, reject) => {
|
|
546
541
|
const commands = getCommands(getInstallSaveProdSaveExactCommands(deps, r, f))
|
|
542
|
+
const options = getOptions(directory)
|
|
547
543
|
|
|
548
544
|
const {
|
|
549
545
|
stdout,
|
|
550
546
|
stderr
|
|
551
|
-
} = exec(commands,
|
|
547
|
+
} = exec(commands, options, (e, v) => {
|
|
552
548
|
(!e)
|
|
553
549
|
? resolve(v)
|
|
554
550
|
: reject(e)
|
|
@@ -577,18 +573,19 @@ export function installSaveProdSaveExact (d, deps, r, f) {
|
|
|
577
573
|
export function installSaveProd (d, deps, r, f) {
|
|
578
574
|
log('installSaveProd')
|
|
579
575
|
|
|
580
|
-
const directory = normalize(d)
|
|
576
|
+
const directory = normalize(d.trim())
|
|
581
577
|
|
|
582
578
|
log(`Directory is "${directory}"`)
|
|
583
579
|
|
|
584
580
|
return (
|
|
585
581
|
new Promise((resolve, reject) => {
|
|
586
582
|
const commands = getCommands(getInstallSaveProdCommands(deps, r, f))
|
|
583
|
+
const options = getOptions(directory)
|
|
587
584
|
|
|
588
585
|
const {
|
|
589
586
|
stdout,
|
|
590
587
|
stderr
|
|
591
|
-
} = exec(commands,
|
|
588
|
+
} = exec(commands, options, (e, v) => {
|
|
592
589
|
(!e)
|
|
593
590
|
? resolve(v)
|
|
594
591
|
: reject(e)
|
package/src/install/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
getForceParameter,
|
|
32
32
|
getSaveExactParameter,
|
|
33
33
|
getCommands,
|
|
34
|
+
getOptions,
|
|
34
35
|
normalizeCommands,
|
|
35
36
|
transform,
|
|
36
37
|
getDepsExact,
|
|
@@ -41,22 +42,10 @@ const log = debug('@modernpoacher/deps:install')
|
|
|
41
42
|
|
|
42
43
|
log(`\`install\` (${VERSION} - ${PLATFORM}) is awake`)
|
|
43
44
|
|
|
44
|
-
const OPTIONS = {
|
|
45
|
-
maxBuffer: 1024 * 2000,
|
|
46
|
-
stdio: 'inherit',
|
|
47
|
-
env: {
|
|
48
|
-
DEBUG_COLORS: 'yes',
|
|
49
|
-
FORCE_COLOR: PLATFORM === 'win32'
|
|
50
|
-
? 3
|
|
51
|
-
: 2,
|
|
52
|
-
PATH: process.env.PATH
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
45
|
/**
|
|
57
46
|
* @function getInstallSaveExactCommands
|
|
58
47
|
*
|
|
59
|
-
* Get the `install --save-exact` commands as a string
|
|
48
|
+
* Get the `install --save-exact` commands as a string
|
|
60
49
|
*
|
|
61
50
|
* @param {Package} p - Package
|
|
62
51
|
* @param {boolean} s - Save
|
|
@@ -79,7 +68,7 @@ export function getInstallSaveExactCommands (p, s, r, f) {
|
|
|
79
68
|
/**
|
|
80
69
|
* @function getInstallCommands
|
|
81
70
|
*
|
|
82
|
-
* Get the `install` commands as a string
|
|
71
|
+
* Get the `install` commands as a string
|
|
83
72
|
*
|
|
84
73
|
* @param {Package} p - Package
|
|
85
74
|
* @param {boolean} s - Save
|
|
@@ -115,18 +104,19 @@ export function getInstallCommands (p, s, r, f) {
|
|
|
115
104
|
export function installSaveExact (d, p, s, r, f) {
|
|
116
105
|
log('installSaveExact')
|
|
117
106
|
|
|
118
|
-
const directory = normalize(d)
|
|
107
|
+
const directory = normalize(d.trim())
|
|
119
108
|
|
|
120
109
|
log(`Directory is "${directory}"`)
|
|
121
110
|
|
|
122
111
|
return (
|
|
123
112
|
new Promise((resolve, reject) => {
|
|
124
113
|
const commands = getCommands(getInstallSaveExactCommands(p, s, r, f))
|
|
114
|
+
const options = getOptions(directory)
|
|
125
115
|
|
|
126
116
|
const {
|
|
127
117
|
stdout,
|
|
128
118
|
stderr
|
|
129
|
-
} = exec(commands,
|
|
119
|
+
} = exec(commands, options, (e, v) => {
|
|
130
120
|
(!e)
|
|
131
121
|
? resolve(v)
|
|
132
122
|
: reject(e)
|
|
@@ -154,18 +144,19 @@ export function installSaveExact (d, p, s, r, f) {
|
|
|
154
144
|
export function install (d, p, s, r, f) {
|
|
155
145
|
log('install')
|
|
156
146
|
|
|
157
|
-
const directory = normalize(d)
|
|
147
|
+
const directory = normalize(d.trim())
|
|
158
148
|
|
|
159
149
|
log(`Directory is "${directory}"`)
|
|
160
150
|
|
|
161
151
|
return (
|
|
162
152
|
new Promise((resolve, reject) => {
|
|
163
153
|
const commands = getCommands(getInstallCommands(p, s, r, f))
|
|
154
|
+
const options = getOptions(directory)
|
|
164
155
|
|
|
165
156
|
const {
|
|
166
157
|
stdout,
|
|
167
158
|
stderr
|
|
168
|
-
} = exec(commands,
|
|
159
|
+
} = exec(commands, options, (e, v) => {
|
|
169
160
|
(!e)
|
|
170
161
|
? resolve(v)
|
|
171
162
|
: reject(e)
|