@@ -7,7 +7,6 @@ const meow = require('meow');
7
7
const Promise = require ( 'bluebird' ) ;
8
8
const pkgConf = require ( 'pkg-conf' ) ;
9
9
const isCi = require ( 'is-ci' ) ;
10
- const hasFlag = require ( 'has-flag' ) ;
11
10
const Api = require ( '../api' ) ;
12
11
const colors = require ( './colors' ) ;
13
12
const VerboseReporter = require ( './reporters/verbose' ) ;
@@ -32,86 +31,82 @@ exports.run = () => {
32
31
33
32
Options
34
33
--init Add AVA to your project
34
+ --watch, -w Re-run tests when tests and source files change
35
+ --match, -m Only run tests with matching title (Can be repeated)
36
+ --update-snapshots, -u Update snapshots
35
37
--fail-fast Stop after first test failure
38
+ --timeout, -T Set global timeout
36
39
--serial, -s Run tests serially
37
- --tap , -t Generate TAP output
40
+ --concurrency , -c Max number of test files running at the same time (Default: CPU cores)
38
41
--verbose, -v Enable verbose output
39
- --no-cache Disable the transpiler cache
42
+ --tap, -t Generate TAP output
43
+ --no-cache Disable the compiler cache
40
44
--color Force color output
41
45
--no-color Disable color output
42
- --match, -m Only run tests with matching title (Can be repeated)
43
- --watch, -w Re-run tests when tests and source files change
44
- --timeout, -T Set global timeout
45
- --concurrency, -c Max number of test files running at the same time (Default: CPU cores)
46
- --update-snapshots, -u Update snapshots
47
46
48
47
Examples
49
48
ava
50
49
ava test.js test2.js
51
50
ava test-*.js
52
51
ava test
53
52
ava --init
54
- ava --init foo.js
55
53
56
54
Default patterns when no arguments:
57
55
test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js
58
56
` , {
59
57
flags : {
58
+ init : {
59
+ type : 'boolean'
60
+ } ,
61
+ watch : {
62
+ type : 'boolean' ,
63
+ alias : 'w'
64
+ } ,
60
65
match : {
61
66
type : 'string' ,
62
67
alias : 'm' ,
63
68
default : conf . match
64
69
} ,
65
- timeout : {
66
- type : 'string' ,
67
- alias : 'T' ,
68
- default : conf . timeout
69
- } ,
70
- concurrency : {
71
- type : 'string' ,
72
- alias : 'c' ,
73
- default : conf . concurrency
74
- } ,
75
- init : {
70
+ 'update-snapshots' : {
76
71
type : 'boolean' ,
77
- default : conf . init
72
+ alias : 'u'
78
73
} ,
79
74
'fail-fast' : {
80
75
type : 'boolean' ,
81
76
default : conf . failFast
82
77
} ,
78
+ timeout : {
79
+ type : 'string' ,
80
+ alias : 'T' ,
81
+ default : conf . timeout
82
+ } ,
83
83
serial : {
84
84
type : 'boolean' ,
85
85
alias : 's' ,
86
86
default : conf . serial
87
87
} ,
88
- tap : {
89
- type : 'boolean ' ,
90
- alias : 't ' ,
91
- default : conf . tap
88
+ concurrency : {
89
+ type : 'string ' ,
90
+ alias : 'c ' ,
91
+ default : conf . concurrency
92
92
} ,
93
93
verbose : {
94
94
type : 'boolean' ,
95
95
alias : 'v' ,
96
96
default : conf . verbose
97
97
} ,
98
- watch : {
98
+ tap : {
99
99
type : 'boolean' ,
100
- alias : 'w ' ,
101
- default : conf . watch
100
+ alias : 't ' ,
101
+ default : conf . tap
102
102
} ,
103
- 'update-snapshots' : {
103
+ cache : {
104
104
type : 'boolean' ,
105
- alias : 'u' ,
106
- default : conf . updateSnapshots
105
+ default : conf . cache !== false
107
106
} ,
108
107
color : {
109
108
type : 'boolean' ,
110
109
default : 'color' in conf ? conf . color : require ( 'supports-color' ) . stdout !== false
111
- } ,
112
- cache : {
113
- type : 'boolean' ,
114
- default : conf . cache !== false
115
110
}
116
111
}
117
112
} ) ;
@@ -123,28 +118,23 @@ exports.run = () => {
123
118
return ;
124
119
}
125
120
126
- if (
127
- ( ( hasFlag ( '--watch' ) || hasFlag ( '-w' ) ) && ( hasFlag ( '--tap' ) || hasFlag ( '-t' ) ) ) ||
128
- ( conf . watch && conf . tap )
129
- ) {
130
- throw new Error ( colors . error ( figures . cross ) + ' The TAP reporter is not available when using watch mode.' ) ;
121
+ if ( cli . flags . watch && cli . flags . tap && ! conf . tap ) {
122
+ throw new Error ( `${ colors . error ( figures . cross ) } The TAP reporter is not available when using watch mode.` ) ;
131
123
}
132
124
133
- if ( ( hasFlag ( '-- watch' ) || hasFlag ( '-w' ) ) && isCi ) {
134
- throw new Error ( colors . error ( figures . cross ) + ' Watch mode is not available in CI, as it prevents AVA from terminating.' ) ;
125
+ if ( cli . flags . watch && isCi ) {
126
+ throw new Error ( ` ${ colors . error ( figures . cross ) } Watch mode is not available in CI, as it prevents AVA from terminating.` ) ;
135
127
}
136
128
137
- if ( cli . flags . concurrency === '' ) {
138
- throw new Error ( colors . error ( figures . cross ) + ' The --concurrency and -c flags must be provided.' ) ;
139
- }
140
-
141
- if ( cli . flags . concurrency &&
142
- ( ! Number . isInteger ( Number . parseFloat ( cli . flags . concurrency ) ) || parseInt ( cli . flags . concurrency , 10 ) < 0 ) ) {
143
- throw new Error ( colors . error ( figures . cross ) + ' The --concurrency and -c flags must be a nonnegative integer.' ) ;
129
+ if (
130
+ cli . flags . concurrency === '' ||
131
+ ( cli . flags . concurrency && ( ! Number . isInteger ( Number . parseFloat ( cli . flags . concurrency ) ) || parseInt ( cli . flags . concurrency , 10 ) < 0 ) )
132
+ ) {
133
+ throw new Error ( `${ colors . error ( figures . cross ) } The --concurrency or -c flag must be provided with a nonnegative integer.` ) ;
144
134
}
145
135
146
- if ( hasFlag ( '--require' ) || hasFlag ( '-r' ) ) {
147
- throw new Error ( colors . error ( figures . cross ) + ' The --require and -r flags are deprecated. Requirements should be configured in package.json - see documentation.' ) ;
136
+ if ( 'source' in conf ) {
137
+ throw new Error ( ` ${ colors . error ( figures . cross ) } The 'source' option has been renamed. Use 'sources' instead.` ) ;
148
138
}
149
139
150
140
// Copy resultant cli.flags into conf for use with Api and elsewhere
@@ -197,7 +187,7 @@ exports.run = () => {
197
187
198
188
if ( conf . watch ) {
199
189
try {
200
- const watcher = new Watcher ( logger , api , files , arrify ( conf . source ) ) ;
190
+ const watcher = new Watcher ( logger , api , files , arrify ( conf . sources ) ) ;
201
191
watcher . observeStdin ( process . stdin ) ;
202
192
} catch ( err ) {
203
193
if ( err . name === 'AvaError' ) {
0 commit comments