Skip to content

Commit 6883743

Browse files
committedJan 23, 2024
deps: @npmcli/[email protected]
1 parent 8382fb3 commit 6883743

10 files changed

+51
-47
lines changed
 

‎DEPENDENCIES.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ graph LR;
224224
npmcli-package-json-->proc-log;
225225
npmcli-package-json-->semver;
226226
npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"];
227+
npmcli-run-script-->npmcli-package-json["@npmcli/package-json"];
227228
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
228-
npmcli-run-script-->read-package-json-fast;
229229
npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"];
230230
npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"];
231231
npmcli-smoke-tests-->npmcli-promise-spawn["@npmcli/promise-spawn"];
@@ -702,8 +702,8 @@ graph LR;
702702
npmcli-query-->postcss-selector-parser;
703703
npmcli-run-script-->node-gyp;
704704
npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"];
705+
npmcli-run-script-->npmcli-package-json["@npmcli/package-json"];
705706
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
706-
npmcli-run-script-->read-package-json-fast;
707707
npmcli-run-script-->which;
708708
npmcli-smoke-tests-->npmcli-eslint-config["@npmcli/eslint-config"];
709709
npmcli-smoke-tests-->npmcli-mock-registry["@npmcli/mock-registry"];
@@ -823,9 +823,10 @@ packages higher up the chain.
823823
- @npmcli/mock-registry, libnpmdiff, libnpmfund, libnpmpack
824824
- @npmcli/arborist
825825
- @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
828829
- @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
831832
- @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

‎node_modules/@npmcli/run-script/lib/is-server-package.js

+3-4
Original file line numberDiff line numberDiff 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+
54
module.exports = async path => {
65
try {
76
const st = await stat(resolve(path, 'server.js'))

‎node_modules/@npmcli/run-script/lib/is-windows.js

-2
This file was deleted.

‎node_modules/@npmcli/run-script/lib/make-spawn-args.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const makeSpawnArgs = options => {
99
path,
1010
scriptShell = true,
1111
binPaths,
12-
env = {},
12+
env,
1313
stdio,
1414
cmd,
15-
args = [],
15+
args,
1616
stdioString,
1717
} = options
1818

Original file line numberDiff line numberDiff 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 = {}) => {
82
for (const [key, val] of Object.entries(vals)) {
93
if (val === undefined) {
104
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)
1313
} else {
14-
env[`${prefix}${key}`] = envVal(val)
14+
env[`${prefix}${key}`] = String(val)
1515
}
1616
}
1717
return env
1818
}
1919

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+
}

‎node_modules/@npmcli/run-script/lib/run-script-pkg.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const runScriptPkg = async options => {
6969
path,
7070
scriptShell,
7171
binPaths,
72-
env: packageEnvs(env, pkg),
72+
env: { ...env, ...packageEnvs(pkg) },
7373
stdio,
7474
cmd,
7575
args,
@@ -93,6 +93,8 @@ const runScriptPkg = async options => {
9393

9494
return p.catch(er => {
9595
const { signal } = er
96+
// coverage disabled because win32 never emits signals
97+
/* istanbul ignore next */
9698
if (stdio === 'inherit' && signal) {
9799
// by the time we reach here, the child has already exited. we send the
98100
// signal back to ourselves again so that npm will exit with the same
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
const rpj = require('read-package-json-fast')
1+
const PackageJson = require('@npmcli/package-json')
22
const runScriptPkg = require('./run-script-pkg.js')
33
const validateOptions = require('./validate-options.js')
44
const isServerPackage = require('./is-server-package.js')
55

6-
const runScript = options => {
6+
const runScript = async options => {
77
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 })
1213
}
1314

1415
module.exports = Object.assign(runScript, { isServerPackage })

‎node_modules/@npmcli/run-script/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/run-script",
3-
"version": "7.0.3",
3+
"version": "7.0.4",
44
"description": "Run a lifecycle script for a package (descendant of npm-lifecycle)",
55
"author": "GitHub Inc.",
66
"license": "ISC",
@@ -17,14 +17,14 @@
1717
"devDependencies": {
1818
"@npmcli/eslint-config": "^4.0.0",
1919
"@npmcli/template-oss": "4.21.3",
20-
"require-inject": "^1.4.4",
20+
"spawk": "^1.8.1",
2121
"tap": "^16.0.1"
2222
},
2323
"dependencies": {
2424
"@npmcli/node-gyp": "^3.0.0",
25+
"@npmcli/package-json": "^5.0.0",
2526
"@npmcli/promise-spawn": "^7.0.0",
2627
"node-gyp": "^10.0.0",
27-
"read-package-json-fast": "^3.0.0",
2828
"which": "^4.0.0"
2929
},
3030
"files": [

‎package-lock.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
"@npmcli/map-workspaces": "^3.0.4",
9696
"@npmcli/package-json": "^5.0.0",
9797
"@npmcli/promise-spawn": "^7.0.1",
98-
"@npmcli/run-script": "^7.0.3",
98+
"@npmcli/run-script": "^7.0.4",
9999
"@sigstore/tuf": "^2.3.0",
100100
"abbrev": "^2.0.0",
101101
"archy": "~1.0.0",
@@ -1877,15 +1877,15 @@
18771877
}
18781878
},
18791879
"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==",
18831883
"inBundle": true,
18841884
"dependencies": {
18851885
"@npmcli/node-gyp": "^3.0.0",
1886+
"@npmcli/package-json": "^5.0.0",
18861887
"@npmcli/promise-spawn": "^7.0.0",
18871888
"node-gyp": "^10.0.0",
1888-
"read-package-json-fast": "^3.0.0",
18891889
"which": "^4.0.0"
18901890
},
18911891
"engines": {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@npmcli/map-workspaces": "^3.0.4",
5959
"@npmcli/package-json": "^5.0.0",
6060
"@npmcli/promise-spawn": "^7.0.1",
61-
"@npmcli/run-script": "^7.0.3",
61+
"@npmcli/run-script": "^7.0.4",
6262
"@sigstore/tuf": "^2.3.0",
6363
"abbrev": "^2.0.0",
6464
"archy": "~1.0.0",

0 commit comments

Comments
 (0)
Please sign in to comment.