Skip to content

Commit 99dc697

Browse files
committed
deps: @npmcli/[email protected]
* unique filename for temporary script files * correctly translate paths when using bash in windows
1 parent a2d700b commit 99dc697

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

node_modules/@npmcli/run-script/lib/escape.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const sh = (input) => {
6868
// disabling the no-control-regex rule for this line as we very specifically _do_ want to
6969
// replace those characters if they somehow exist at this point, which is highly unlikely
7070
// eslint-disable-next-line no-control-regex
71-
const filename = (input) => input.replace(/[<>:"/\\|?*\x00-\x31]/g, '')
71+
const filename = (input) => input.replace(/[<>:"/\\|?*\x00-\x1F]/g, '')
7272

7373
module.exports = {
7474
cmd,

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
/* eslint camelcase: "off" */
22
const isWindows = require('./is-windows.js')
33
const setPATH = require('./set-path.js')
4-
const { chmodSync: chmod, unlinkSync: unlink, writeFileSync: writeFile } = require('fs')
4+
const { unlinkSync: unlink, writeFileSync: writeFile } = require('fs')
55
const { tmpdir } = require('os')
6-
const { isAbsolute, resolve } = require('path')
6+
const { resolve } = require('path')
77
const which = require('which')
88
const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
99
const escape = require('./escape.js')
10+
const { randomBytes } = require('crypto')
11+
12+
const translateWinPathToPosix = (path) => {
13+
return path
14+
.replace(/^([A-z]):/, '/$1')
15+
.replace(/\\/g, '/')
16+
}
1017

1118
const makeSpawnArgs = options => {
1219
const {
@@ -30,7 +37,7 @@ const makeSpawnArgs = options => {
3037
npm_config_node_gyp,
3138
})
3239

33-
const fileName = escape.filename(`${event}-${Date.now()}`)
40+
const fileName = escape.filename(`${event}-${randomBytes(4).toString('hex')}`)
3441
let scriptFile
3542
let script = ''
3643

@@ -69,24 +76,17 @@ const makeSpawnArgs = options => {
6976
script += ` ${args.map((arg) => escape.cmd(arg, doubleEscape)).join(' ')}`
7077
}
7178
} else {
72-
const shebang = isAbsolute(scriptShell)
73-
? `#!${scriptShell}`
74-
: `#!/usr/bin/env ${scriptShell}`
7579
scriptFile = resolve(tmpdir(), `${fileName}.sh`)
76-
script += `${shebang}\n`
77-
script += cmd
80+
script = cmd
7881
if (args.length) {
7982
script += ` ${args.map((arg) => escape.sh(arg)).join(' ')}`
8083
}
8184
}
8285

8386
writeFile(scriptFile, script)
84-
if (!isCmd) {
85-
chmod(scriptFile, '0775')
86-
}
8787
const spawnArgs = isCmd
8888
? ['/d', '/s', '/c', escape.cmd(scriptFile)]
89-
: ['-c', escape.sh(scriptFile)]
89+
: [isWindows ? translateWinPathToPosix(scriptFile) : scriptFile]
9090

9191
const spawnOpts = {
9292
env: spawnEnv,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/run-script",
3-
"version": "4.1.5",
3+
"version": "4.1.7",
44
"description": "Run a lifecycle script for a package (descendant of npm-lifecycle)",
55
"author": "GitHub Inc.",
66
"license": "ISC",

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"@npmcli/fs": "^2.1.0",
9595
"@npmcli/map-workspaces": "^2.0.3",
9696
"@npmcli/package-json": "^2.0.0",
97-
"@npmcli/run-script": "^4.1.5",
97+
"@npmcli/run-script": "^4.1.7",
9898
"abbrev": "~1.1.1",
9999
"archy": "~1.0.0",
100100
"cacache": "^16.1.1",
@@ -1044,9 +1044,9 @@
10441044
}
10451045
},
10461046
"node_modules/@npmcli/run-script": {
1047-
"version": "4.1.5",
1048-
"resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-4.1.5.tgz",
1049-
"integrity": "sha512-FyrZkZ+O0bCnQqm+mRb6sKbEJgyJudInwFN84gCcMUcxrWkR15Ags1uOHwnxHYdpj3T5eqrCZNW/Ys20MGTQ6Q==",
1047+
"version": "4.1.7",
1048+
"resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-4.1.7.tgz",
1049+
"integrity": "sha512-WXr/MyM4tpKA4BotB81NccGAv8B48lNH0gRoILucbcAhTQXLCoi6HflMV3KdXubIqvP9SuLsFn68Z7r4jl+ppw==",
10501050
"inBundle": true,
10511051
"dependencies": {
10521052
"@npmcli/node-gyp": "^2.0.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"@npmcli/fs": "^2.1.0",
6363
"@npmcli/map-workspaces": "^2.0.3",
6464
"@npmcli/package-json": "^2.0.0",
65-
"@npmcli/run-script": "^4.1.5",
65+
"@npmcli/run-script": "^4.1.7",
6666
"abbrev": "~1.1.1",
6767
"archy": "~1.0.0",
6868
"cacache": "^16.1.1",

0 commit comments

Comments
 (0)