/
version.js
53 lines (45 loc) 路 1.13 KB
/
version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import test from 'ava';
import {_verifyCli, defaultFixture, stripIndentTrim} from '../_utils.js';
const verifyVersion = _verifyCli('version/fixture.js');
test('spawn cli and show version', verifyVersion, {
args: '--version',
expected: '1.0.0',
});
test('spawn cli and disabled autoVersion', verifyVersion, {
fixture: defaultFixture,
args: '--version --no-auto-version',
expected: stripIndentTrim`
version
autoVersion
meow
camelCaseOption
`,
});
test('spawn cli and not show version', verifyVersion, {
fixture: defaultFixture,
args: '--version=beta',
expected: stripIndentTrim`
version
meow
camelCaseOption
`,
});
test('custom version', verifyVersion, {
args: '--version',
execaOptions: {env: {VERSION: 'beta'}},
expected: 'beta',
});
test('version = false has no effect', verifyVersion, {
args: '--version',
execaOptions: {env: {VERSION: 'false'}},
expected: 'false',
});
test('manual showVersion', verifyVersion, {
args: '--show-version',
expected: '1.0.0',
});
test('no version fallback message', verifyVersion, {
fixture: 'with-package-json/default/fixture.js',
args: '--version',
expected: 'No version found',
});