libnpmexec 5.0.2 → 5.0.4
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/index.js +33 -17
- package/lib/run-script.js +4 -6
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const { mkdir } = require('fs/promises')
|
|
|
4
4
|
const { promisify } = require('util')
|
|
5
5
|
|
|
6
6
|
const Arborist = require('@npmcli/arborist')
|
|
7
|
-
const
|
|
7
|
+
const ciInfo = require('ci-info')
|
|
8
8
|
const crypto = require('crypto')
|
|
9
9
|
const log = require('proc-log')
|
|
10
10
|
const npa = require('npm-package-arg')
|
|
@@ -79,7 +79,6 @@ const exec = async (opts) => {
|
|
|
79
79
|
const {
|
|
80
80
|
args = [],
|
|
81
81
|
call = '',
|
|
82
|
-
color = false,
|
|
83
82
|
localBin = resolve('./node_modules/.bin'),
|
|
84
83
|
locationMsg = undefined,
|
|
85
84
|
globalBin = '',
|
|
@@ -97,7 +96,6 @@ const exec = async (opts) => {
|
|
|
97
96
|
const run = () => runScript({
|
|
98
97
|
args,
|
|
99
98
|
call,
|
|
100
|
-
color,
|
|
101
99
|
flatOptions,
|
|
102
100
|
locationMsg,
|
|
103
101
|
output,
|
|
@@ -112,22 +110,40 @@ const exec = async (opts) => {
|
|
|
112
110
|
return run()
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
let needPackageCommandSwap = (args.length > 0) && (packages.length === 0)
|
|
116
114
|
// If they asked for a command w/o specifying a package, see if there is a
|
|
117
|
-
// bin that directly matches that name
|
|
115
|
+
// bin that directly matches that name:
|
|
116
|
+
// - in the local package itself
|
|
117
|
+
// - in the local tree
|
|
118
|
+
// - globally
|
|
118
119
|
if (needPackageCommandSwap) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
let localManifest
|
|
121
|
+
try {
|
|
122
|
+
localManifest = await pacote.manifest(path, flatOptions)
|
|
123
|
+
} catch {
|
|
124
|
+
// no local package.json? no problem, move one.
|
|
125
|
+
}
|
|
126
|
+
if (localManifest?.bin?.[args[0]]) {
|
|
127
|
+
// we have to install the local package into the npx cache so that its
|
|
128
|
+
// bin links get set up
|
|
129
|
+
flatOptions.installLinks = false
|
|
130
|
+
// args[0] will exist when the package is installed
|
|
131
|
+
packages.push(path)
|
|
132
|
+
yes = true
|
|
133
|
+
needPackageCommandSwap = false
|
|
134
|
+
} else {
|
|
135
|
+
const dir = dirname(dirname(localBin))
|
|
136
|
+
const localBinPath = await localFileExists(dir, args[0], '/')
|
|
137
|
+
if (localBinPath) {
|
|
138
|
+
binPaths.push(localBinPath)
|
|
139
|
+
return await run()
|
|
140
|
+
} else if (globalPath && await fileExists(`${globalBin}/${args[0]}`)) {
|
|
141
|
+
binPaths.push(globalBin)
|
|
142
|
+
return await run()
|
|
143
|
+
}
|
|
144
|
+
// We swap out args[0] with the bin from the manifest later
|
|
145
|
+
packages.push(args[0])
|
|
127
146
|
}
|
|
128
|
-
|
|
129
|
-
// We swap out args[0] with the bin from the manifest later
|
|
130
|
-
packages.push(args[0])
|
|
131
147
|
}
|
|
132
148
|
|
|
133
149
|
// Resolve any directory specs so that the npx directory is unique to the
|
|
@@ -228,7 +244,7 @@ const exec = async (opts) => {
|
|
|
228
244
|
throw new Error('canceled')
|
|
229
245
|
}
|
|
230
246
|
|
|
231
|
-
if (noTTY() ||
|
|
247
|
+
if (noTTY() || ciInfo.isCI) {
|
|
232
248
|
log.warn('exec', `The following package${
|
|
233
249
|
add.length === 1 ? ' was' : 's were'
|
|
234
250
|
} not found and will be installed: ${
|
package/lib/run-script.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
|
-
const
|
|
2
|
+
const ciInfo = require('ci-info')
|
|
3
3
|
const runScript = require('@npmcli/run-script')
|
|
4
4
|
const readPackageJson = require('read-package-json-fast')
|
|
5
5
|
const npmlog = require('npmlog')
|
|
@@ -15,7 +15,6 @@ const nocolor = {
|
|
|
15
15
|
const run = async ({
|
|
16
16
|
args,
|
|
17
17
|
call,
|
|
18
|
-
color,
|
|
19
18
|
flatOptions,
|
|
20
19
|
locationMsg,
|
|
21
20
|
output = () => {},
|
|
@@ -26,6 +25,7 @@ const run = async ({
|
|
|
26
25
|
}) => {
|
|
27
26
|
// turn list of args into command string
|
|
28
27
|
const script = call || args.shift() || scriptShell
|
|
28
|
+
const color = !!flatOptions.color
|
|
29
29
|
const colorize = color ? chalk : nocolor
|
|
30
30
|
|
|
31
31
|
// do the fakey runScript dance
|
|
@@ -44,10 +44,8 @@ const run = async ({
|
|
|
44
44
|
|
|
45
45
|
try {
|
|
46
46
|
if (script === scriptShell) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (isTTY) {
|
|
50
|
-
if (ciDetect()) {
|
|
47
|
+
if (!noTTY()) {
|
|
48
|
+
if (ciInfo.isCI) {
|
|
51
49
|
return log.warn('exec', 'Interactive mode disabled in CI environment')
|
|
52
50
|
}
|
|
53
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libnpmexec",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"bin/",
|
|
6
6
|
"lib/"
|
|
@@ -51,17 +51,17 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@npmcli/eslint-config": "^4.0.0",
|
|
54
|
-
"@npmcli/template-oss": "4.
|
|
54
|
+
"@npmcli/template-oss": "4.10.0",
|
|
55
55
|
"bin-links": "^4.0.1",
|
|
56
56
|
"minify-registry-metadata": "^2.2.0",
|
|
57
57
|
"mkdirp": "^1.0.4",
|
|
58
58
|
"tap": "^16.0.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@npmcli/arborist": "^6.1.
|
|
62
|
-
"@npmcli/ci-detect": "^3.0.1",
|
|
61
|
+
"@npmcli/arborist": "^6.1.3",
|
|
63
62
|
"@npmcli/run-script": "^6.0.0",
|
|
64
63
|
"chalk": "^4.1.0",
|
|
64
|
+
"ci-info": "^3.6.1",
|
|
65
65
|
"npm-package-arg": "^10.0.0",
|
|
66
66
|
"npmlog": "^7.0.1",
|
|
67
67
|
"pacote": "^15.0.2",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"templateOSS": {
|
|
75
75
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
76
|
-
"version": "4.
|
|
76
|
+
"version": "4.10.0",
|
|
77
77
|
"content": "../../scripts/template-oss/index.js"
|
|
78
78
|
}
|
|
79
79
|
}
|