libnpmexec 3.0.1 → 3.0.2
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/cache-install-dir.js +2 -1
- package/lib/file-exists.js +4 -2
- package/lib/get-bin-from-manifest.js +4 -2
- package/lib/index.js +12 -6
- package/lib/manifest-missing.js +4 -2
- package/lib/run-script.js +6 -3
- package/package.json +14 -12
package/lib/cache-install-dir.js
CHANGED
|
@@ -3,8 +3,9 @@ const crypto = require('crypto')
|
|
|
3
3
|
const { resolve } = require('path')
|
|
4
4
|
|
|
5
5
|
const cacheInstallDir = ({ npxCache, packages }) => {
|
|
6
|
-
if (!npxCache)
|
|
6
|
+
if (!npxCache) {
|
|
7
7
|
throw new Error('Must provide a valid npxCache path')
|
|
8
|
+
}
|
|
8
9
|
|
|
9
10
|
// only packages not found in ${prefix}/node_modules
|
|
10
11
|
return resolve(npxCache, getHash(packages))
|
package/lib/file-exists.js
CHANGED
|
@@ -13,11 +13,13 @@ const localFileExists = async (dir, binName, root = '/') => {
|
|
|
13
13
|
for (const path of walkUp(resolve(dir))) {
|
|
14
14
|
const binDir = resolve(path, 'node_modules', '.bin')
|
|
15
15
|
|
|
16
|
-
if (await fileExists(resolve(binDir, binName)))
|
|
16
|
+
if (await fileExists(resolve(binDir, binName))) {
|
|
17
17
|
return binDir
|
|
18
|
+
}
|
|
18
19
|
|
|
19
|
-
if (path.toLowerCase() === root)
|
|
20
|
+
if (path.toLowerCase() === root) {
|
|
20
21
|
return false
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
return false
|
|
@@ -3,13 +3,15 @@ const getBinFromManifest = (mani) => {
|
|
|
3
3
|
// otherwise if there's 1 bin or all bin value is the same (alias), use
|
|
4
4
|
// that, otherwise fail
|
|
5
5
|
const bin = mani.bin || {}
|
|
6
|
-
if (new Set(Object.values(bin)).size === 1)
|
|
6
|
+
if (new Set(Object.values(bin)).size === 1) {
|
|
7
7
|
return Object.keys(bin)[0]
|
|
8
|
+
}
|
|
8
9
|
|
|
9
10
|
// XXX probably a util to parse this better?
|
|
10
11
|
const name = mani.name.replace(/^@[^/]+\//, '')
|
|
11
|
-
if (bin[name])
|
|
12
|
+
if (bin[name]) {
|
|
12
13
|
return name
|
|
14
|
+
}
|
|
13
15
|
|
|
14
16
|
// XXX need better error message
|
|
15
17
|
throw Object.assign(new Error('could not determine executable to run'), {
|
package/lib/index.js
CHANGED
|
@@ -59,8 +59,9 @@ const exec = async (opts) => {
|
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
// nothing to maybe install, skip the arborist dance
|
|
62
|
-
if (!call && !args.length && !packages.length)
|
|
62
|
+
if (!call && !args.length && !packages.length) {
|
|
63
63
|
return await _run()
|
|
64
|
+
}
|
|
64
65
|
|
|
65
66
|
const needPackageCommandSwap = args.length && !packages.length
|
|
66
67
|
// if there's an argument and no package has been explicitly asked for
|
|
@@ -79,8 +80,9 @@ const exec = async (opts) => {
|
|
|
79
80
|
binExists = true
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
if (binExists)
|
|
83
|
+
if (binExists) {
|
|
83
84
|
return await _run()
|
|
85
|
+
}
|
|
84
86
|
|
|
85
87
|
packages.push(args[0])
|
|
86
88
|
}
|
|
@@ -109,8 +111,9 @@ const exec = async (opts) => {
|
|
|
109
111
|
})
|
|
110
112
|
}))
|
|
111
113
|
|
|
112
|
-
if (needPackageCommandSwap)
|
|
114
|
+
if (needPackageCommandSwap) {
|
|
113
115
|
args[0] = getBinFromManifest(manis[0])
|
|
116
|
+
}
|
|
114
117
|
|
|
115
118
|
// figure out whether we need to install stuff, or if local is fine
|
|
116
119
|
const localArb = new Arborist({
|
|
@@ -150,8 +153,9 @@ const exec = async (opts) => {
|
|
|
150
153
|
if (add.length) {
|
|
151
154
|
if (!yes) {
|
|
152
155
|
// set -n to always say no
|
|
153
|
-
if (yes === false)
|
|
156
|
+
if (yes === false) {
|
|
154
157
|
throw new Error('canceled')
|
|
158
|
+
}
|
|
155
159
|
|
|
156
160
|
if (noTTY() || ciDetect()) {
|
|
157
161
|
log.warn('exec', `The following package${
|
|
@@ -165,11 +169,13 @@ const exec = async (opts) => {
|
|
|
165
169
|
const prompt = `Need to install the following packages:\n${
|
|
166
170
|
addList
|
|
167
171
|
}Ok to proceed? `
|
|
168
|
-
if (typeof log.clearProgress === 'function')
|
|
172
|
+
if (typeof log.clearProgress === 'function') {
|
|
169
173
|
log.clearProgress()
|
|
174
|
+
}
|
|
170
175
|
const confirm = await read({ prompt, default: 'y' })
|
|
171
|
-
if (confirm.trim().toLowerCase().charAt(0) !== 'y')
|
|
176
|
+
if (confirm.trim().toLowerCase().charAt(0) !== 'y') {
|
|
172
177
|
throw new Error('canceled')
|
|
178
|
+
}
|
|
173
179
|
}
|
|
174
180
|
}
|
|
175
181
|
await arb.reify({
|
package/lib/manifest-missing.js
CHANGED
|
@@ -3,12 +3,14 @@ const manifestMissing = ({ tree, manifest }) => {
|
|
|
3
3
|
// true means we need to install it
|
|
4
4
|
const child = tree.children.get(manifest.name)
|
|
5
5
|
// if no child, we have to load it
|
|
6
|
-
if (!child)
|
|
6
|
+
if (!child) {
|
|
7
7
|
return true
|
|
8
|
+
}
|
|
8
9
|
|
|
9
10
|
// if no version/tag specified, allow whatever's there
|
|
10
|
-
if (manifest._from === `${manifest.name}@`)
|
|
11
|
+
if (manifest._from === `${manifest.name}@`) {
|
|
11
12
|
return false
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
// otherwise the version has to match what we WOULD get
|
|
14
16
|
return child.version !== manifest.version
|
package/lib/run-script.js
CHANGED
|
@@ -41,16 +41,18 @@ const run = async ({
|
|
|
41
41
|
},
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (log && log.disableProgress)
|
|
44
|
+
if (log && log.disableProgress) {
|
|
45
45
|
log.disableProgress()
|
|
46
|
+
}
|
|
46
47
|
|
|
47
48
|
try {
|
|
48
49
|
if (script === scriptShell) {
|
|
49
50
|
const isTTY = !noTTY()
|
|
50
51
|
|
|
51
52
|
if (isTTY) {
|
|
52
|
-
if (ciDetect())
|
|
53
|
+
if (ciDetect()) {
|
|
53
54
|
return log.warn('exec', 'Interactive mode disabled in CI environment')
|
|
55
|
+
}
|
|
54
56
|
|
|
55
57
|
locationMsg = locationMsg || ` at location:\n${colorize.dim(runPath)}`
|
|
56
58
|
|
|
@@ -78,8 +80,9 @@ const run = async ({
|
|
|
78
80
|
stdio: 'inherit',
|
|
79
81
|
})
|
|
80
82
|
} finally {
|
|
81
|
-
if (log && log.enableProgress)
|
|
83
|
+
if (log && log.enableProgress) {
|
|
82
84
|
log.enableProgress()
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libnpmexec",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"files": [
|
|
5
|
+
"bin",
|
|
5
6
|
"lib"
|
|
6
7
|
],
|
|
7
8
|
"main": "lib/index.js",
|
|
@@ -28,25 +29,23 @@
|
|
|
28
29
|
],
|
|
29
30
|
"license": "ISC",
|
|
30
31
|
"scripts": {
|
|
31
|
-
"lint": "eslint
|
|
32
|
-
"
|
|
33
|
-
"test": "tap
|
|
34
|
-
"snap": "tap
|
|
32
|
+
"lint": "eslint '**/*.js'",
|
|
33
|
+
"posttest": "npm run lint",
|
|
34
|
+
"test": "tap",
|
|
35
|
+
"snap": "tap",
|
|
35
36
|
"preversion": "npm test",
|
|
36
37
|
"postversion": "npm publish",
|
|
37
|
-
"prepublishOnly": "git push origin --follow-tags"
|
|
38
|
+
"prepublishOnly": "git push origin --follow-tags",
|
|
39
|
+
"postlint": "npm-template-check",
|
|
40
|
+
"lintfix": "npm run lint -- --fix"
|
|
38
41
|
},
|
|
39
42
|
"tap": {
|
|
40
43
|
"color": true,
|
|
41
|
-
"check-coverage": true
|
|
44
|
+
"check-coverage": true,
|
|
45
|
+
"files": "test/*.js"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"bin-links": "^2.2.1",
|
|
45
|
-
"eslint": "^7.24.0",
|
|
46
|
-
"eslint-plugin-import": "^2.22.1",
|
|
47
|
-
"eslint-plugin-node": "^11.1.0",
|
|
48
|
-
"eslint-plugin-promise": "^5.1.0",
|
|
49
|
-
"eslint-plugin-standard": "^5.0.0",
|
|
50
49
|
"tap": "^15.0.6"
|
|
51
50
|
},
|
|
52
51
|
"dependencies": {
|
|
@@ -61,5 +60,8 @@
|
|
|
61
60
|
"read": "^1.0.7",
|
|
62
61
|
"read-package-json-fast": "^2.0.2",
|
|
63
62
|
"walk-up-path": "^1.0.0"
|
|
63
|
+
},
|
|
64
|
+
"templateOSS": {
|
|
65
|
+
"version": "2.4.1"
|
|
64
66
|
}
|
|
65
67
|
}
|