Skip to content

Commit eeeb3f4

Browse files
nlfruyadorno
authored andcommittedMar 9, 2021
remove puka
PR-URL: #22 Credit: @nlf Close: #22 Reviewed-by: @ruyadorno
1 parent f976fd3 commit eeeb3f4

File tree

4 files changed

+4
-37
lines changed

4 files changed

+4
-37
lines changed
 

‎lib/make-spawn-args.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@ const isWindows = require('./is-windows.js')
33
const setPATH = require('./set-path.js')
44
const {resolve} = require('path')
55
const npm_config_node_gyp = require.resolve('node-gyp/bin/node-gyp.js')
6-
const { quoteForShell, ShellString, ShellStringText, ShellStringUnquoted } = require('puka')
7-
8-
const escapeCmd = cmd => {
9-
const result = []
10-
const parsed = ShellString.sh([cmd])
11-
for (const child of parsed.children) {
12-
if (child instanceof ShellStringText) {
13-
const children = child.contents.filter(segment => segment !== null).map(segment => quoteForShell(segment, false, isWindows && 'win32'))
14-
result.push(...children)
15-
} else if (child instanceof ShellStringUnquoted) {
16-
result.push(child.value)
17-
} else {
18-
result.push(isWindows ? '&' : ';')
19-
}
20-
}
21-
22-
return result.join('')
23-
}
246

257
const makeSpawnArgs = options => {
268
const {
@@ -34,7 +16,7 @@ const makeSpawnArgs = options => {
3416
} = options
3517

3618
const isCmd = /(?:^|\\)cmd(?:\.exe)?$/i.test(scriptShell)
37-
const args = isCmd ? ['/d', '/s', '/c', escapeCmd(cmd)] : ['-c', cmd]
19+
const args = isCmd ? ['/d', '/s', '/c', cmd] : ['-c', cmd]
3820

3921
const spawnOpts = {
4022
env: setPATH(path, {

‎package-lock.json

-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@npmcli/promise-spawn": "^1.3.2",
3333
"infer-owner": "^1.0.4",
3434
"node-gyp": "^7.1.0",
35-
"puka": "^1.0.1",
3635
"read-package-json-fast": "^2.0.1"
3736
},
3837
"files": [

‎test/make-spawn-args.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (isWindows) {
2424
cmd: 'script "quoted parameter"; second command',
2525
}), [
2626
'cmd',
27-
[ '/d', '/s', '/c', `script "quoted parameter"& second command` ],
27+
[ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ],
2828
{
2929
env: {
3030
npm_package_json: /package\.json$/,
@@ -66,7 +66,7 @@ if (isWindows) {
6666
scriptShell: 'cmd.exe',
6767
}), [
6868
'cmd.exe',
69-
[ '/d', '/s', '/c', `script "quoted parameter"& second command` ],
69+
[ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ],
7070
{
7171
env: {
7272
npm_package_json: /package\.json$/,
@@ -113,7 +113,7 @@ if (isWindows) {
113113
scriptShell: 'cmd.exe',
114114
}), [
115115
'cmd.exe',
116-
[ '/d', '/s', '/c', `script 'quoted parameter'; second command` ],
116+
[ '/d', '/s', '/c', `script \"quoted parameter\"; second command` ],
117117
{
118118
env: {
119119
npm_package_json: /package\.json$/,

0 commit comments

Comments
 (0)
Please sign in to comment.