+51
-47
lines changedFilter options
+51
-47
lines changed Original file line number Diff line number Diff line change
@@ -224,8 +224,8 @@ graph LR;
224
224
npmcli-package-json-->proc-log;
225
225
npmcli-package-json-->semver;
226
226
npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"];
227
+
npmcli-run-script-->npmcli-package-json["@npmcli/package-json"];
227
228
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
228
-
npmcli-run-script-->read-package-json-fast;
229
229
npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"];
230
230
npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"];
231
231
npmcli-smoke-tests-->npmcli-promise-spawn["@npmcli/promise-spawn"];
@@ -702,8 +702,8 @@ graph LR;
702
702
npmcli-query-->postcss-selector-parser;
703
703
npmcli-run-script-->node-gyp;
704
704
npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"];
705
+
npmcli-run-script-->npmcli-package-json["@npmcli/package-json"];
705
706
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
706
-
npmcli-run-script-->read-package-json-fast;
707
707
npmcli-run-script-->which;
708
708
npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"];
709
709
npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"];
@@ -823,9 +823,10 @@ packages higher up the chain.
823
823
- @npmcli/mock-registry, libnpmdiff, libnpmfund, libnpmpack
824
824
- @npmcli/arborist
825
825
- @npmcli/metavuln-calculator
826
-
- pacote, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile
827
-
- npm-registry-fetch, @npmcli/package-json, libnpmversion
826
+
- pacote, libnpmversion
827
+
- @npmcli/run-script, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile
828
+
- @npmcli/package-json, npm-registry-fetch
828
829
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
829
-
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, promzard
830
-
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, bin-links, nopt, npmlog, parse-conflict-json, @npmcli/mock-globals, read
830
+
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, read-package-json, promzard
831
+
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, normalize-package-data, npm-packlist, bin-links, nopt, npmlog, parse-conflict-json, @npmcli/mock-globals, read
831
832
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, minify-registry-metadata, ini, @npmcli/disparity-colors, mute-stream, npm-audit-report, npm-user-validate
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
1
-
const util = require('util')
2
-
const fs = require('fs')
3
-
const { stat } = fs.promises || { stat: util.promisify(fs.stat) }
4
-
const { resolve } = require('path')
1
+
const { stat } = require('node:fs/promises')
2
+
const { resolve } = require('node:path')
3
+
5
4
module.exports = async path => {
6
5
try {
7
6
const st = await stat(resolve(path, 'server.js'))
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ const makeSpawnArgs = options => {
9
9
path,
10
10
scriptShell = true,
11
11
binPaths,
12
-
env = {},
12
+
env,
13
13
stdio,
14
14
cmd,
15
-
args = [],
15
+
args,
16
16
stdioString,
17
17
} = options
18
18
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
1
-
// https://github.com/npm/rfcs/pull/183
2
-
3
-
const envVal = val => Array.isArray(val) ? val.map(v => envVal(v)).join('\n\n')
4
-
: val === null || val === false ? ''
5
-
: String(val)
6
-
7
-
const packageEnvs = (env, vals, prefix) => {
1
+
const packageEnvs = (vals, prefix, env = {}) => {
8
2
for (const [key, val] of Object.entries(vals)) {
9
3
if (val === undefined) {
10
4
continue
11
-
} else if (val && !Array.isArray(val) && typeof val === 'object') {
12
-
packageEnvs(env, val, `${prefix}${key}_`)
5
+
} else if (val === null || val === false) {
6
+
env[`${prefix}${key}`] = ''
7
+
} else if (Array.isArray(val)) {
8
+
val.forEach((item, index) => {
9
+
packageEnvs({ [`${key}_${index}`]: item }, `${prefix}`, env)
10
+
})
11
+
} else if (typeof val === 'object') {
12
+
packageEnvs(val, `${prefix}${key}_`, env)
13
13
} else {
14
-
env[`${prefix}${key}`] = envVal(val)
14
+
env[`${prefix}${key}`] = String(val)
15
15
}
16
16
}
17
17
return env
18
18
}
19
19
20
-
module.exports = (env, pkg) => packageEnvs({ ...env }, {
21
-
name: pkg.name,
22
-
version: pkg.version,
23
-
config: pkg.config,
24
-
engines: pkg.engines,
25
-
bin: pkg.bin,
26
-
}, 'npm_package_')
20
+
// https://github.com/npm/rfcs/pull/183 defines which fields we put into the environment
21
+
module.exports = pkg => {
22
+
return packageEnvs({
23
+
name: pkg.name,
24
+
version: pkg.version,
25
+
config: pkg.config,
26
+
engines: pkg.engines,
27
+
bin: pkg.bin,
28
+
}, 'npm_package_')
29
+
}
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ const runScriptPkg = async options => {
69
69
path,
70
70
scriptShell,
71
71
binPaths,
72
-
env: packageEnvs(env, pkg),
72
+
env: { ...env, ...packageEnvs(pkg) },
73
73
stdio,
74
74
cmd,
75
75
args,
@@ -93,6 +93,8 @@ const runScriptPkg = async options => {
93
93
94
94
return p.catch(er => {
95
95
const { signal } = er
96
+
// coverage disabled because win32 never emits signals
97
+
/* istanbul ignore next */
96
98
if (stdio === 'inherit' && signal) {
97
99
// by the time we reach here, the child has already exited. we send the
98
100
// signal back to ourselves again so that npm will exit with the same
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
1
-
const rpj = require('read-package-json-fast')
1
+
const PackageJson = require('@npmcli/package-json')
2
2
const runScriptPkg = require('./run-script-pkg.js')
3
3
const validateOptions = require('./validate-options.js')
4
4
const isServerPackage = require('./is-server-package.js')
5
5
6
-
const runScript = options => {
6
+
const runScript = async options => {
7
7
validateOptions(options)
8
-
const { pkg, path } = options
9
-
return pkg ? runScriptPkg(options)
10
-
: rpj(path + '/package.json')
11
-
.then(readPackage => runScriptPkg({ ...options, pkg: readPackage }))
8
+
if (options.pkg) {
9
+
return runScriptPkg(options)
10
+
}
11
+
const { content: pkg } = await PackageJson.normalize(options.path)
12
+
return runScriptPkg({ ...options, pkg })
12
13
}
13
14
14
15
module.exports = Object.assign(runScript, { isServerPackage })
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@npmcli/run-script",
3
-
"version": "7.0.3",
3
+
"version": "7.0.4",
4
4
"description": "Run a lifecycle script for a package (descendant of npm-lifecycle)",
5
5
"author": "GitHub Inc.",
6
6
"license": "ISC",
@@ -17,14 +17,14 @@
17
17
"devDependencies": {
18
18
"@npmcli/eslint-config": "^4.0.0",
19
19
"@npmcli/template-oss": "4.21.3",
20
-
"require-inject": "^1.4.4",
20
+
"spawk": "^1.8.1",
21
21
"tap": "^16.0.1"
22
22
},
23
23
"dependencies": {
24
24
"@npmcli/node-gyp": "^3.0.0",
25
+
"@npmcli/package-json": "^5.0.0",
25
26
"@npmcli/promise-spawn": "^7.0.0",
26
27
"node-gyp": "^10.0.0",
27
-
"read-package-json-fast": "^3.0.0",
28
28
"which": "^4.0.0"
29
29
},
30
30
"files": [
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@
95
95
"@npmcli/map-workspaces": "^3.0.4",
96
96
"@npmcli/package-json": "^5.0.0",
97
97
"@npmcli/promise-spawn": "^7.0.1",
98
-
"@npmcli/run-script": "^7.0.3",
98
+
"@npmcli/run-script": "^7.0.4",
99
99
"@sigstore/tuf": "^2.3.0",
100
100
"abbrev": "^2.0.0",
101
101
"archy": "~1.0.0",
@@ -1877,15 +1877,15 @@
1877
1877
}
1878
1878
},
1879
1879
"node_modules/@npmcli/run-script": {
1880
-
"version": "7.0.3",
1881
-
"resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-7.0.3.tgz",
1882
-
"integrity": "sha512-ZMWGLHpzMq3rBGIwPyeaoaleaLMvrBrH8nugHxTi5ACkJZXTxXPtVuEH91ifgtss5hUwJQ2VDnzDBWPmz78rvg==",
1880
+
"version": "7.0.4",
1881
+
"resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-7.0.4.tgz",
1882
+
"integrity": "sha512-9ApYM/3+rBt9V80aYg6tZfzj3UWdiYyCt7gJUD1VJKvWF5nwKDSICXbYIQbspFTq6TOpbsEtIC0LArB8d9PFmg==",
1883
1883
"inBundle": true,
1884
1884
"dependencies": {
1885
1885
"@npmcli/node-gyp": "^3.0.0",
1886
+
"@npmcli/package-json": "^5.0.0",
1886
1887
"@npmcli/promise-spawn": "^7.0.0",
1887
1888
"node-gyp": "^10.0.0",
1888
-
"read-package-json-fast": "^3.0.0",
1889
1889
"which": "^4.0.0"
1890
1890
},
1891
1891
"engines": {
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@
58
58
"@npmcli/map-workspaces": "^3.0.4",
59
59
"@npmcli/package-json": "^5.0.0",
60
60
"@npmcli/promise-spawn": "^7.0.1",
61
-
"@npmcli/run-script": "^7.0.3",
61
+
"@npmcli/run-script": "^7.0.4",
62
62
"@sigstore/tuf": "^2.3.0",
63
63
"abbrev": "^2.0.0",
64
64
"archy": "~1.0.0",
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4