Skip to content

Commit

Permalink
chore: test for early version exit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 24, 2024
1 parent 7ca6d84 commit 3cbc258
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/lib/cli/entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const t = require('tap')
const { readdirSync } = require('fs')
const { dirname } = require('path')
const { load: loadMockNpm } = require('../../fixtures/mock-npm.js')
const tmock = require('../../fixtures/tmock.js')
Expand Down Expand Up @@ -170,3 +171,14 @@ t.test('non-ascii dash', async t => {
'arg Argument starts with non-ascii dash, this is probably invalid: \u2010not-a-dash'
)
})

t.test('exit early for --version', async t => {
const { cli, outputs, Npm, cache } = await cliMock(t, {
globals: {
'process.argv': ['node', 'npm', '-v'],
},
})
await cli(process)
t.strictSame(readdirSync(cache), [], 'nothing created in cache')
t.equal(outputs[0], Npm.version)
})

0 comments on commit 3cbc258

Please sign in to comment.