Skip to content

Commit

Permalink
fix: pnpm should exit with non-zero code
Browse files Browse the repository at this point in the history
Running "pnpm" without any command should print help
and exit with a non-zero exit code.

PR #2334
ref #2325
  • Loading branch information
zkochan committed Feb 4, 2020
1 parent eb548d0 commit ea26d50
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/pnpm/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,7 @@ export default async function run (inputArgv: string[]) {
}
}, 0)
})
if (!cmd) {
process.exit(1)
}
}
9 changes: 9 additions & 0 deletions packages/pnpm/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ test('pnpm fails when an unsupported command is used', async (t) => {
t.ok(stderr.toString().includes("Unknown command 'unsupported-command'"))
})

test('pnpm fails when no command is specified', async (t) => {
const project = prepare(t)

const { status, stdout } = execPnpmSync()

t.equal(status, 1, 'command failed')
t.ok(stdout.toString().includes('Usage:'))
})

test('command fails when an unsupported flag is used', async (t) => {
const project = prepare(t)

Expand Down

0 comments on commit ea26d50

Please sign in to comment.