@@ -7,10 +7,12 @@ var bail = require('bail')
7
7
var test = require ( 'tape' )
8
8
var touch = require ( 'touch' )
9
9
var strip = require ( 'strip-ansi' )
10
+ var figures = require ( 'figures' )
10
11
11
12
var join = path . join
12
13
var read = fs . readFileSync
13
14
var rm = fs . unlinkSync
15
+ var sep = path . sep
14
16
15
17
var fixtures = join ( __dirname , 'fixtures' )
16
18
@@ -31,7 +33,7 @@ test('unified-args', function(t) {
31
33
'missing.txt' ,
32
34
' 1:1 error No such file or directory' ,
33
35
'' ,
34
- '✖ 1 error',
36
+ figures . cross + ' 1 error',
35
37
''
36
38
] . join ( '\n' )
37
39
@@ -61,8 +63,8 @@ test('unified-args', function(t) {
61
63
t . test ( 'should accept a path to a directory' , function ( st ) {
62
64
var expected = [
63
65
'one.txt: no issues found' ,
64
- 'three/ five.txt: no issues found' ,
65
- 'three/ four.txt: no issues found' ,
66
+ 'three' + sep + ' five.txt: no issues found',
67
+ 'three' + sep + ' four.txt: no issues found',
66
68
'two.txt: no issues found'
67
69
] . join ( '\n' )
68
70
@@ -100,8 +102,8 @@ test('unified-args', function(t) {
100
102
101
103
t . test ( 'should accept a glob to a directory' , function ( st ) {
102
104
var expected = [
103
- 'three/ five.txt: no issues found' ,
104
- 'three/ four.txt: no issues found'
105
+ 'three' + sep + ' five.txt: no issues found',
106
+ 'three' + sep + ' four.txt: no issues found'
105
107
] . join ( '\n' )
106
108
107
109
st . plan ( 1 )
@@ -118,7 +120,7 @@ test('unified-args', function(t) {
118
120
} )
119
121
120
122
t . test ( 'should fail on a bad short flag' , function ( st ) {
121
- var expected = read ( join ( cwd , 'SHORT_FLAG' ) , 'utf8' )
123
+ var expected = read ( join ( cwd , 'SHORT_FLAG' ) , 'utf8' ) . replace ( / \r / g , '' )
122
124
123
125
st . plan ( 1 )
124
126
@@ -130,7 +132,7 @@ test('unified-args', function(t) {
130
132
} )
131
133
132
134
t . test ( 'should fail on a bad grouped short flag' , function ( st ) {
133
- var expected = read ( join ( cwd , 'SHORT_FLAG' ) , 'utf8' )
135
+ var expected = read ( join ( cwd , 'SHORT_FLAG' ) , 'utf8' ) . replace ( / \r / g , '' )
134
136
135
137
st . plan ( 1 )
136
138
@@ -142,7 +144,7 @@ test('unified-args', function(t) {
142
144
} )
143
145
144
146
t . test ( 'should fail on a bad long flag' , function ( st ) {
145
- var expected = read ( join ( cwd , 'LONG_FLAG' ) , 'utf8' )
147
+ var expected = read ( join ( cwd , 'LONG_FLAG' ) , 'utf8' ) . replace ( / \r / g , '' )
146
148
147
149
st . plan ( 1 )
148
150
@@ -155,7 +157,9 @@ test('unified-args', function(t) {
155
157
156
158
helpFlags . forEach ( function ( flag ) {
157
159
t . test ( 'should show help on `' + flag + '`' , function ( st ) {
158
- var expected = read ( join ( cwd , 'HELP' ) , 'utf8' ) . trim ( )
160
+ var expected = read ( join ( cwd , 'HELP' ) , 'utf8' )
161
+ . replace ( / \r / g, '' )
162
+ . trim ( )
159
163
160
164
st . plan ( 1 )
161
165
@@ -209,8 +213,8 @@ test('unified-args', function(t) {
209
213
var expected = [
210
214
'alpha.text: no issues found' ,
211
215
'bravo.text: no issues found' ,
212
- 'charlie/ delta.text: no issues found' ,
213
- 'charlie/ echo.text: no issues found'
216
+ 'charlie' + sep + ' delta.text: no issues found',
217
+ 'charlie' + sep + ' echo.text: no issues found'
214
218
] . join ( '\n' )
215
219
216
220
st . plan ( 1 )
@@ -243,8 +247,8 @@ test('unified-args', function(t) {
243
247
var expected = [
244
248
'alpha.text: no issues found' ,
245
249
'bravo.text: no issues found' ,
246
- 'charlie/ delta.text: no issues found' ,
247
- 'charlie/ echo.text: no issues found'
250
+ 'charlie' + sep + ' delta.text: no issues found',
251
+ 'charlie' + sep + ' echo.text: no issues found'
248
252
] . join ( '\n' )
249
253
250
254
st . plan ( 1 )
@@ -448,7 +452,12 @@ test('unified-args', function(t) {
448
452
touch . sync ( doc )
449
453
450
454
proc = execa ( bin , [ 'watch.txt' , '-w' ] )
451
- proc . then ( onsuccess , st . fail )
455
+
456
+ if ( process . platform === 'win32' ) {
457
+ proc . then ( st . fail , onsuccess )
458
+ } else {
459
+ proc . then ( onsuccess , st . fail )
460
+ }
452
461
453
462
setTimeout ( seeYouLaterAlligator , delay )
454
463
@@ -475,14 +484,21 @@ test('unified-args', function(t) {
475
484
} )
476
485
477
486
t . test ( 'should not regenerate when watching' , function ( st ) {
478
- var expected = [
487
+ var lines = [
479
488
'Watching... (press CTRL+C to exit)' ,
480
489
'Note: Ignoring `--output` until exit.' ,
481
490
'watch.txt: no issues found' ,
482
491
'watch.txt: no issues found' ,
483
- '' ,
484
- 'watch.txt: written'
485
- ] . join ( '\n' )
492
+ ''
493
+ ]
494
+
495
+ // Windows immediatly quits.
496
+ // Other OSes support cleaning up things.
497
+ if ( process . platform !== 'win32' ) {
498
+ lines . push ( 'watch.txt: written' )
499
+ }
500
+
501
+ var expected = lines . join ( '\n' )
486
502
var doc = join ( cwd , 'watch.txt' )
487
503
var resolved = false
488
504
var delay = 3000
@@ -492,8 +508,13 @@ test('unified-args', function(t) {
492
508
493
509
touch . sync ( doc )
494
510
495
- proc = execa ( bin , [ 'watch.txt' , '-wo' ] )
496
- proc . then ( onsuccess , st . fail )
511
+ proc = execa ( bin , [ 'watch.txt' , '-w' , '-o' ] )
512
+
513
+ if ( process . platform === 'win32' ) {
514
+ proc . then ( st . fail , onsuccess )
515
+ } else {
516
+ proc . then ( onsuccess , st . fail )
517
+ }
497
518
498
519
setTimeout ( seeYouLaterAlligator , delay )
499
520
0 commit comments