Skip to content

Commit e16a800

Browse files
committed
Minor npm npx raw-npm command cleanup
1 parent 7067331 commit e16a800

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

src/commands/npm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const description = 'npm wrapper functionality'
1010
export const npm: CliSubcommand = {
1111
description,
1212
async run(argv, _importMeta, _ctx) {
13-
process.exitCode = 1
1413
const wrapperPath = path.join(distPath, 'npm-cli.js')
14+
process.exitCode = 1
1515
const spawnPromise = spawn(process.execPath, [wrapperPath, ...argv], {
1616
stdio: 'inherit'
1717
})

src/commands/npx.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export const npx: CliSubcommand = {
1111
description,
1212
async run(argv, _importMeta, _ctx) {
1313
const wrapperPath = path.join(distPath, 'npx-cli.js')
14-
1514
process.exitCode = 1
16-
1715
const spawnPromise = spawn(process.execPath, [wrapperPath, ...argv], {
1816
stdio: 'inherit'
1917
})

src/commands/raw-npm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async function setupCommand(
5555
cli.showHelp()
5656
return
5757
}
58-
const spawnPromise = spawn('npm', [argv.join(' ')], {
58+
const spawnPromise = spawn('npm', <string[]>argv, {
5959
stdio: 'inherit'
6060
})
6161
spawnPromise.process.on('exit', (code, signal) => {

src/shadow/npm-cli.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ const realDirname = path.dirname(realFilename)
1414
const npmPath = installLinks(path.join(realDirname, 'bin'), 'npm')
1515
const injectionPath = path.join(realDirname, 'npm-injection.js')
1616

17-
process.exitCode = 1
18-
19-
/*
20-
Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
21-
is found to fix a UX issue when running the command with recent versions of npm
22-
(input swallowed by the standard npm spinner)
23-
*/
17+
// Adding the `--quiet` and `--no-progress` flags when the `proc-log` module
18+
// is found to fix a UX issue when running the command with recent versions of
19+
// npm (input swallowed by the standard npm spinner)
2420
let npmArgs: string[] = []
2521
if (process.argv.slice(2).includes('install')) {
2622
const npmEntrypoint = realpathSync(npmPath)
@@ -29,7 +25,6 @@ if (process.argv.slice(2).includes('install')) {
2925
process.exit(127)
3026
}
3127
const npmDepPath = path.join(npmRootPath, 'node_modules')
32-
3328
let npmlog
3429
try {
3530
npmlog = require(path.join(npmDepPath, 'proc-log/lib/index.js')).log
@@ -39,16 +34,19 @@ if (process.argv.slice(2).includes('install')) {
3934
}
4035
}
4136

42-
spawn(
37+
process.exitCode = 1
38+
const spawnPromise = spawn(
4339
process.execPath,
4440
['--require', injectionPath, npmPath, ...process.argv.slice(2), ...npmArgs],
4541
{
4642
stdio: 'inherit'
4743
}
48-
).process.on('exit', (code, signal) => {
44+
)
45+
spawnPromise.process.on('exit', (code, signal) => {
4946
if (signal) {
5047
process.kill(process.pid, signal)
5148
} else if (code !== null) {
5249
process.exit(code)
5350
}
5451
})
52+
void spawnPromise

src/shadow/npx-cli.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const npxPath = installLinks(path.join(realDirname, 'bin'), 'npx')
1414
const injectionPath = path.join(realDirname, 'npm-injection.js')
1515

1616
process.exitCode = 1
17-
1817
const spawnPromise = spawn(
1918
process.execPath,
2019
['--require', injectionPath, npxPath, ...process.argv.slice(2)],

0 commit comments

Comments
 (0)