diff --git a/lib/make-spawn-args.js b/lib/make-spawn-args.js index 4c38b94..8ee24c0 100644 --- a/lib/make-spawn-args.js +++ b/lib/make-spawn-args.js @@ -3,24 +3,6 @@ const isWindows = require('./is-windows.js') const setPATH = require('./set-path.js') const {resolve} = require('path') const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js') -const { quoteForShell, ShellString, ShellStringText, ShellStringUnquoted } = require('puka') - -const escapeCmd = cmd => { - const result = [] - const parsed = ShellString.sh([cmd]) - for (const child of parsed.children) { - if (child instanceof ShellStringText) { - const children = child.contents.filter(segment => segment !== null).map(segment => quoteForShell(segment, false, isWindows && 'win32')) - result.push(...children) - } else if (child instanceof ShellStringUnquoted) { - result.push(child.value) - } else { - result.push(isWindows ? '&' : ';') - } - } - - return result.join('') -} const makeSpawnArgs = options => { const { @@ -34,7 +16,7 @@ const makeSpawnArgs = options => { } = options const isCmd = /(?:^|\\)cmd(?:\.exe)?$/i.test(scriptShell) - const args = isCmd ? ['/d', '/s', '/c', escapeCmd(cmd)] : ['-c', cmd] + const args = isCmd ? ['/d', '/s', '/c', cmd] : ['-c', cmd] const spawnOpts = { env: setPATH(path, { diff --git a/package-lock.json b/package-lock.json index 9cedafe..22aaf9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@npmcli/promise-spawn": "^1.3.2", "infer-owner": "^1.0.4", "node-gyp": "^7.1.0", - "puka": "^1.0.1", "read-package-json-fast": "^2.0.1" }, "devDependencies": { @@ -3337,14 +3336,6 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" }, - "node_modules/puka": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/puka/-/puka-1.0.1.tgz", - "integrity": "sha512-ssjRZxBd7BT3dte1RR3VoeT2cT/ODH8x+h0rUF1rMqB0srHYf48stSDWfiYakTp5UBZMxroZhB2+ExLDHm7W3g==", - "engines": { - "node": ">=4" - } - }, "node_modules/punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -9397,11 +9388,6 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==" }, - "puka": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/puka/-/puka-1.0.1.tgz", - "integrity": "sha512-ssjRZxBd7BT3dte1RR3VoeT2cT/ODH8x+h0rUF1rMqB0srHYf48stSDWfiYakTp5UBZMxroZhB2+ExLDHm7W3g==" - }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", diff --git a/package.json b/package.json index 9df5b31..14fea3d 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@npmcli/promise-spawn": "^1.3.2", "infer-owner": "^1.0.4", "node-gyp": "^7.1.0", - "puka": "^1.0.1", "read-package-json-fast": "^2.0.1" }, "files": [ diff --git a/test/make-spawn-args.js b/test/make-spawn-args.js index 3aec461..a4e9963 100644 --- a/test/make-spawn-args.js +++ b/test/make-spawn-args.js @@ -24,7 +24,7 @@ if (isWindows) { cmd: 'script "quoted parameter"; second command', }), [ 'cmd', - [ '/d', '/s', '/c', `script "quoted parameter"& second command` ], + [ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ], { env: { npm_package_json: /package\.json$/, @@ -66,7 +66,7 @@ if (isWindows) { scriptShell: 'cmd.exe', }), [ 'cmd.exe', - [ '/d', '/s', '/c', `script "quoted parameter"& second command` ], + [ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ], { env: { npm_package_json: /package\.json$/, @@ -113,7 +113,7 @@ if (isWindows) { scriptShell: 'cmd.exe', }), [ 'cmd.exe', - [ '/d', '/s', '/c', `script 'quoted parameter'; second command` ], + [ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ], { env: { npm_package_json: /package\.json$/,