Skip to content

Commit

Permalink
deps: @npmcli/promise-spawn@7.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed May 7, 2024
1 parent 6dfaebb commit 8234412
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 49 deletions.
77 changes: 39 additions & 38 deletions node_modules/@npmcli/promise-spawn/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,55 @@ const promiseSpawn = (cmd, args, opts = {}, extra = {}) => {
return spawnWithShell(cmd, args, opts, extra)
}

let proc
let resolve, reject
const promise = new Promise((_resolve, _reject) => {
resolve = _resolve
reject = _reject
})

const p = new Promise((res, rej) => {
proc = spawn(cmd, args, opts)
// Create error here so we have a more useful stack trace when rejecting
const closeError = new Error('command failed')

const stdout = []
const stderr = []
const stdout = []
const stderr = []

const reject = er => rej(Object.assign(er, {
cmd,
args,
...stdioResult(stdout, stderr, opts),
...extra,
}))
const getResult = (result) => ({
cmd,
args,
...result,
...stdioResult(stdout, stderr, opts),
...extra,
})
const rejectWithOpts = (er, erOpts) => {
const resultError = getResult(erOpts)
reject(Object.assign(er, resultError))
}

proc.on('error', reject)
const proc = spawn(cmd, args, opts)
promise.stdin = proc.stdin
promise.process = proc

if (proc.stdout) {
proc.stdout.on('data', c => stdout.push(c)).on('error', reject)
proc.stdout.on('error', er => reject(er))
}
proc.on('error', rejectWithOpts)

if (proc.stderr) {
proc.stderr.on('data', c => stderr.push(c)).on('error', reject)
proc.stderr.on('error', er => reject(er))
}
if (proc.stdout) {
proc.stdout.on('data', c => stdout.push(c))
proc.stdout.on('error', rejectWithOpts)
}

proc.on('close', (code, signal) => {
const result = {
cmd,
args,
code,
signal,
...stdioResult(stdout, stderr, opts),
...extra,
}
if (proc.stderr) {
proc.stderr.on('data', c => stderr.push(c))
proc.stderr.on('error', rejectWithOpts)
}

if (code || signal) {
rej(Object.assign(new Error('command failed'), result))
} else {
res(result)
}
})
proc.on('close', (code, signal) => {
if (code || signal) {
rejectWithOpts(closeError, { code, signal })
} else {
resolve(getResult({ code, signal }))
}
})

p.stdin = proc.stdin
p.process = proc
return p
return promise
}

const spawnWithShell = (cmd, args, opts, extra) => {
Expand Down
8 changes: 4 additions & 4 deletions node_modules/@npmcli/promise-spawn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/promise-spawn",
"version": "7.0.1",
"version": "7.0.2",
"files": [
"bin/",
"lib/"
Expand All @@ -9,7 +9,7 @@
"description": "spawn processes the way the npm cli likes to do",
"repository": {
"type": "git",
"url": "https://github.com/npm/promise-spawn.git"
"url": "git+https://github.com/npm/promise-spawn.git"
},
"author": "GitHub Inc.",
"license": "ISC",
Expand All @@ -32,7 +32,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.21.3",
"@npmcli/template-oss": "4.22.0",
"spawk": "^1.7.1",
"tap": "^16.0.1"
},
Expand All @@ -41,7 +41,7 @@
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.21.3",
"version": "4.22.0",
"publish": true
},
"dependencies": {
Expand Down
11 changes: 6 additions & 5 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@npmcli/fs": "^3.1.0",
"@npmcli/map-workspaces": "^3.0.6",
"@npmcli/package-json": "^5.1.0",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/redact": "^2.0.0",
"@npmcli/run-script": "^8.1.0",
"@sigstore/tuf": "^2.3.2",
Expand Down Expand Up @@ -1690,10 +1690,11 @@
}
},
"node_modules/@npmcli/promise-spawn": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-7.0.1.tgz",
"integrity": "sha512-P4KkF9jX3y+7yFUxgcUdDtLy+t4OlDGuEBLNs57AZsfSfg+uV6MLndqGpnl4831ggaEdXwR50XFoZP4VFtHolg==",
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/@npmcli/promise-spawn/-/promise-spawn-7.0.2.tgz",
"integrity": "sha512-xhfYPXoV5Dy4UkY0D+v2KkwvnDfiA/8Mt3sWCGI/hM03NsYIH8ZaG6QzS9x7pje5vHZBZJ2v6VRFVTWACnqcmQ==",
"inBundle": true,
"license": "ISC",
"dependencies": {
"which": "^4.0.0"
},
Expand Down Expand Up @@ -14763,7 +14764,7 @@
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/promise-spawn": "^7.0.0",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/template-oss": "4.22.0",
"proxy": "^2.1.1",
"semver": "^7.5.4",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@npmcli/fs": "^3.1.0",
"@npmcli/map-workspaces": "^3.0.6",
"@npmcli/package-json": "^5.1.0",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/redact": "^2.0.0",
"@npmcli/run-script": "^8.1.0",
"@sigstore/tuf": "^2.3.2",
Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/promise-spawn": "^7.0.0",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/template-oss": "4.22.0",
"proxy": "^2.1.1",
"semver": "^7.5.4",
Expand Down

0 comments on commit 8234412

Please sign in to comment.