@@ -11,7 +11,7 @@ var assert = require('assert'),
11
11
watch = require ( '../../lib/monitor/watch' ) ,
12
12
merge = nodemonUtils . merge ;
13
13
14
- describe ( 'match' , function ( ) {
14
+ describe ( 'match' , function ( ) {
15
15
var monitor = [
16
16
'!.git' ,
17
17
'!node_modules/*' ,
@@ -26,10 +26,7 @@ describe('match', function() {
26
26
const cwd = process . cwd ( ) ;
27
27
const res = match (
28
28
[ cwd + '/app.nodemon' ] ,
29
- [
30
- './*.nodemon' ,
31
- '!**/dir/*.nodemon' ,
32
- ] ,
29
+ [ './*.nodemon' , '!**/dir/*.nodemon' ] ,
33
30
'js,mjs,json,nodemon'
34
31
) ;
35
32
@@ -40,10 +37,7 @@ describe('match', function() {
40
37
const cwd = process . cwd ( ) ;
41
38
const res = match (
42
39
[ cwd + '/dir/app.nodemon' ] ,
43
- [
44
- './*.nodemon' ,
45
- '!**/dir/*.nodemon' ,
46
- ] ,
40
+ [ './*.nodemon' , '!**/dir/*.nodemon' ] ,
47
41
'js,mjs,json,nodemon'
48
42
) ;
49
43
@@ -55,10 +49,7 @@ describe('match', function() {
55
49
const cwd = process . cwd ( ) ;
56
50
const res = match (
57
51
[ cwd + '/app.nodemon' ] ,
58
- [
59
- '!./*.nodemon' ,
60
- '**/dir/*.nodemon' ,
61
- ] ,
52
+ [ '!./*.nodemon' , '**/dir/*.nodemon' ] ,
62
53
'js,mjs,json,nodemon'
63
54
) ;
64
55
@@ -83,7 +74,7 @@ describe('match', function() {
83
74
assert . equal ( res . result . length , 1 , JSON . stringify ( res ) ) ;
84
75
} ) ;
85
76
86
- it ( 'should match zero files' , function ( ) {
77
+ it ( 'should match zero files' , function ( ) {
87
78
var files = [
88
79
'views/server/remy.coffee' ,
89
80
'random.coffee' ,
@@ -94,7 +85,7 @@ describe('match', function() {
94
85
assert ( results . result . length === 0 , 'matched ' + results . result . length ) ;
95
86
} ) ;
96
87
97
- it ( 'should match one file' , function ( ) {
88
+ it ( 'should match one file' , function ( ) {
98
89
var files = [
99
90
'views/server/remy.js' ,
100
91
'random.coffee' ,
@@ -105,7 +96,7 @@ describe('match', function() {
105
96
assert ( results . result . length === 1 , 'matched ' + results . result . length ) ;
106
97
} ) ;
107
98
108
- it ( 'should match two files' , function ( ) {
99
+ it ( 'should match two files' , function ( ) {
109
100
var files = [
110
101
'views/server/test.js' ,
111
102
'views/server/test2.js' ,
@@ -116,7 +107,7 @@ describe('match', function() {
116
107
assert ( results . result . length === 2 , 'matched ' + results . result . length ) ;
117
108
} ) ;
118
109
119
- it ( 'should match one file' , function ( ) {
110
+ it ( 'should match one file' , function ( ) {
120
111
var files = [
121
112
'views/server/remy.js' ,
122
113
'views/server/ignore.js' ,
@@ -129,7 +120,7 @@ describe('match', function() {
129
120
assert ( results . result . length === 1 , 'matched ' + results . result . length ) ;
130
121
} ) ;
131
122
132
- it ( 'should apply *.js to any js file' , function ( ) {
123
+ it ( 'should apply *.js to any js file' , function ( ) {
133
124
var files = [ utils . appjs ] ;
134
125
135
126
var result = match ( files , [ '*.*' ] , 'js' ) ;
@@ -139,7 +130,7 @@ describe('match', function() {
139
130
assert ( result . watched === files . length , 'a single file was matched' ) ;
140
131
} ) ;
141
132
142
- it ( 'should ignore .coffee if watching *.js' , function ( ) {
133
+ it ( 'should ignore .coffee if watching *.js' , function ( ) {
143
134
var files = [ utils . appcoffee ] ;
144
135
145
136
var result = match ( files , [ '*.*' ] , 'js' ) ;
@@ -151,12 +142,12 @@ describe('match', function() {
151
142
) ;
152
143
} ) ;
153
144
154
- it ( 'should match .coffee if watching *.js & *.coffee' , function ( done ) {
145
+ it ( 'should match .coffee if watching *.js & *.coffee' , function ( done ) {
155
146
config . load (
156
147
{
157
148
ext : 'js coffee' ,
158
149
} ,
159
- function ( config ) {
150
+ function ( config ) {
160
151
var files = [ utils . appcoffee ] ;
161
152
162
153
var result = match (
@@ -172,8 +163,8 @@ describe('match', function() {
172
163
) ;
173
164
} ) ;
174
165
175
- it ( 'should ignore nodemon default rules' , function ( done ) {
176
- config . load ( { ext : '*.js' } , function ( config ) {
166
+ it ( 'should ignore nodemon default rules' , function ( done ) {
167
+ config . load ( { ext : '*.js' } , function ( config ) {
177
168
var files = [ utils . appjs , path . join ( __dirname , '/.git/foo.js' ) ] ;
178
169
179
170
var result = match (
@@ -190,13 +181,13 @@ describe('match', function() {
190
181
} ) ;
191
182
} ) ;
192
183
193
- it ( 'should ignore directories' , function ( done ) {
184
+ it ( 'should ignore directories' , function ( done ) {
194
185
config . load (
195
186
{
196
187
ext : 'js' ,
197
188
ignore : 'test/fixtures' ,
198
189
} ,
199
- function ( config ) {
190
+ function ( config ) {
200
191
var files = [ utils . appjs ] ;
201
192
202
193
var result = match (
@@ -211,12 +202,12 @@ describe('match', function() {
211
202
) ;
212
203
} ) ;
213
204
214
- it ( 'should check all directories by default' , function ( done ) {
205
+ it ( 'should check all directories by default' , function ( done ) {
215
206
config . load (
216
207
{
217
208
ext : 'js' ,
218
209
} ,
219
- function ( config ) {
210
+ function ( config ) {
220
211
var files = [ utils . appjs ] ;
221
212
var result = match (
222
213
files ,
@@ -229,7 +220,7 @@ describe('match', function() {
229
220
) ;
230
221
} ) ;
231
222
232
- it ( 'should support old .nodemonignore' , function ( done ) {
223
+ it ( 'should support old .nodemonignore' , function ( done ) {
233
224
// prevents our test from finding the nodemon.json files
234
225
var pwd = process . cwd ( ) ,
235
226
old = nodemonUtils . home ;
@@ -238,7 +229,7 @@ describe('match', function() {
238
229
nodemonUtils . home = path . resolve ( pwd , 'test/fixtures/legacy' ) ;
239
230
240
231
// will load the legacy file format
241
- config . load ( { script : utils . appjs , ext : 'js json' } , function ( config ) {
232
+ config . load ( { script : utils . appjs , ext : 'js json' } , function ( config ) {
242
233
var files = [ utils . appjs ] ;
243
234
var result = match (
244
235
files ,
@@ -263,13 +254,13 @@ describe('match', function() {
263
254
} ) ;
264
255
} ) ;
265
256
266
- it ( 'should be specific about directories' , function ( done ) {
257
+ it ( 'should be specific about directories' , function ( done ) {
267
258
config . load (
268
259
{
269
260
ext : 'js md pug' ,
270
261
watch : [ 'lib' ] ,
271
262
} ,
272
- function ( config ) {
263
+ function ( config ) {
273
264
var files = [ utils . appjs ] ;
274
265
var result = match (
275
266
files ,
@@ -283,12 +274,12 @@ describe('match', function() {
283
274
) ;
284
275
} ) ;
285
276
286
- it ( 'should not match coffee when monitoring just js' , function ( done ) {
277
+ it ( 'should not match coffee when monitoring just js' , function ( done ) {
287
278
config . load (
288
279
{
289
280
script : utils . appjs ,
290
281
} ,
291
- function ( config ) {
282
+ function ( config ) {
292
283
var result = match (
293
284
[ utils . appcoffee ] ,
294
285
config . options . monitor ,
@@ -301,7 +292,7 @@ describe('match', function() {
301
292
) ;
302
293
} ) ;
303
294
304
- it ( 'should ignore case when comparing paths on Windows' , function ( ) {
295
+ it ( 'should ignore case when comparing paths on Windows' , function ( ) {
305
296
if ( ! nodemonUtils . isWindows ) {
306
297
return ;
307
298
}
@@ -310,8 +301,8 @@ describe('match', function() {
310
301
} ) ;
311
302
} ) ;
312
303
313
- describe ( 'validating files that cause restart' , function ( ) {
314
- it ( 'should allow for relative paths outside of the cwd' , function ( ) {
304
+ describe ( 'validating files that cause restart' , function ( ) {
305
+ it ( 'should allow for relative paths outside of the cwd' , function ( ) {
315
306
var cwd = process . cwd ( ) ;
316
307
var dir = cwd + '/test/fixtures/configs' ;
317
308
process . chdir ( dir ) ;
@@ -338,7 +329,7 @@ describe('validating files that cause restart', function() {
338
329
) ;
339
330
} ) ;
340
331
341
- it ( 'should allow *.js to match at the top level' , function ( ) {
332
+ it ( 'should allow *.js to match at the top level' , function ( ) {
342
333
var filename = path . join ( 'test' , 'fixtures' , 'configs' , 'top-level.json' ) ;
343
334
var config = JSON . parse ( fs . readFileSync ( filename ) ) ;
344
335
var settings = merge ( config , defaults ) ;
@@ -357,7 +348,7 @@ describe('validating files that cause restart', function() {
357
348
assert ( matched . result . length === 1 , 'found match ' + matched . results ) ;
358
349
} ) ;
359
350
360
- it ( 'should allow for simple star rule: public/*' , function ( ) {
351
+ it ( 'should allow for simple star rule: public/*' , function ( ) {
361
352
var filename = path . join ( 'test' , 'fixtures' , 'configs' , 'public-star.json' ) ;
362
353
var config = JSON . parse ( fs . readFileSync ( filename ) ) ;
363
354
var settings = merge ( config , defaults ) ;
@@ -376,7 +367,7 @@ describe('validating files that cause restart', function() {
376
367
assert ( matched . result . length === 0 , 'public/* ignored: ' + matched . results ) ;
377
368
} ) ;
378
369
379
- it ( 'should allow for relative paths with extensions' , function ( ) {
370
+ it ( 'should allow for relative paths with extensions' , function ( ) {
380
371
var cwd = process . cwd ( ) ;
381
372
var dir = cwd + '/test/fixtures/configs' ;
382
373
process . chdir ( dir ) ;
@@ -404,8 +395,8 @@ describe('validating files that cause restart', function() {
404
395
} ) ;
405
396
} ) ;
406
397
407
- describe ( 'match rule parser' , function ( ) {
408
- it ( 'should support "--watch ."' , function ( ) {
398
+ describe ( 'match rule parser' , function ( ) {
399
+ it ( 'should support "--watch ."' , function ( ) {
409
400
var config = { watch : '.' } ;
410
401
var settings = merge ( config , defaults ) ;
411
402
var script = 'index.js' ;
@@ -423,7 +414,7 @@ describe('match rule parser', function() {
423
414
assert ( matched . result . length === 1 , 'no file matched' ) ;
424
415
} ) ;
425
416
426
- it ( 'should support "--watch .*"' , function ( ) {
417
+ it ( 'should support "--watch .*"' , function ( ) {
427
418
var config = { watch : '.*' } ;
428
419
var settings = merge ( config , defaults ) ;
429
420
var script = 'index.js' ;
@@ -441,7 +432,7 @@ describe('match rule parser', function() {
441
432
assert ( matched . result . length === 1 , 'no file matched' ) ;
442
433
} ) ;
443
434
444
- it ( 'should support "--watch <single file>"' , function ( ) {
435
+ it ( 'should support "--watch <single file>"' , function ( ) {
445
436
var config = { watch : 'config.json' } ;
446
437
var settings = merge ( config , defaults ) ;
447
438
@@ -454,7 +445,7 @@ describe('match rule parser', function() {
454
445
assert ( matched . result . length === 1 , 'no file matched' ) ;
455
446
} ) ;
456
447
457
- it ( 'should support "--watch /some/path/*/config.json"' , function ( ) {
448
+ it ( 'should support "--watch /some/path/*/config.json"' , function ( ) {
458
449
var config = { watch : '/*/config.json' } ;
459
450
var settings = merge ( config , defaults ) ;
460
451
@@ -467,7 +458,7 @@ describe('match rule parser', function() {
467
458
assert ( matched . result . length === 1 , 'no file matched' ) ;
468
459
} ) ;
469
460
470
- it ( 'should support "--watch *.*"' , function ( ) {
461
+ it ( 'should support "--watch *.*"' , function ( ) {
471
462
var config = { watch : '*.*' } ;
472
463
var settings = merge ( config , defaults ) ;
473
464
var script = 'index.js' ;
@@ -485,7 +476,7 @@ describe('match rule parser', function() {
485
476
assert ( matched . result . length === 1 , 'no file matched' ) ;
486
477
} ) ;
487
478
488
- it ( 'should support "--watch .."' , function ( ) {
479
+ it ( 'should support "--watch .."' , function ( ) {
489
480
// make sure we're in a deep enough directory
490
481
var cwd = process . cwd ( ) ;
491
482
process . chdir ( './test/fixtures/' ) ;
@@ -510,42 +501,42 @@ describe('match rule parser', function() {
510
501
} ) ;
511
502
} ) ;
512
503
513
- describe ( 'watcher' , function ( ) {
514
- afterEach ( function ( done ) {
504
+ describe ( 'watcher' , function ( ) {
505
+ afterEach ( function ( done ) {
515
506
config . reset ( ) ;
516
507
setTimeout ( ( ) => {
517
508
watch . resetWatchers ( ) ;
518
509
done ( ) ;
519
510
} , 0 ) ;
520
511
} ) ;
521
512
522
- it ( 'should not crash if ignoreRoot is an empty array' , function ( done ) {
513
+ it ( 'should not crash if ignoreRoot is an empty array' , function ( done ) {
523
514
config . load (
524
515
{
525
516
watch : [ 'test/fixtures/app.js' ] ,
526
517
ignoreRoot : [ ] ,
527
518
} ,
528
- function ( config ) {
519
+ function ( config ) {
529
520
return watch
530
521
. watch ( )
531
- . then ( function ( ) {
522
+ . then ( function ( ) {
532
523
done ( ) ;
533
524
} )
534
525
. catch ( done ) ;
535
526
}
536
527
) ;
537
528
} ) ;
538
529
539
- it ( 'should not match a dotfile unless explicitly asked to' , function ( done ) {
530
+ it ( 'should not match a dotfile unless explicitly asked to' , function ( done ) {
540
531
config . load (
541
532
{
542
533
watch : [ 'test/fixtures/*' ] ,
543
534
} ,
544
- function ( config ) {
535
+ function ( config ) {
545
536
return watch
546
537
. watch ( )
547
- . then ( function ( files ) {
548
- var withDotfile = files . filter ( function ( file ) {
538
+ . then ( function ( files ) {
539
+ var withDotfile = files . filter ( function ( file ) {
549
540
return / t e s t \/ f i x t u r e s \/ \. d o t f i l e $ / . test ( file ) ;
550
541
} ) ;
551
542
assert . deepEqual (
@@ -560,17 +551,17 @@ describe('watcher', function() {
560
551
) ;
561
552
} ) ;
562
553
563
- it ( 'should match a dotfile if explicitly asked to' , function ( done ) {
554
+ it ( 'should match a dotfile if explicitly asked to' , function ( done ) {
564
555
config . load (
565
556
{
566
557
watch : [ 'test/fixtures/.dotfile' ] ,
567
558
} ,
568
- function ( config ) {
559
+ function ( config ) {
569
560
return watch
570
561
. watch ( )
571
- . then ( function ( files ) {
562
+ . then ( function ( files ) {
572
563
assert . deepEqual (
573
- files . filter ( f => f . endsWith ( '.dotfile' ) ) . length ,
564
+ files . filter ( ( f ) => f . endsWith ( '.dotfile' ) ) . length ,
574
565
1 ,
575
566
'should contain .dotfile'
576
567
) ;
@@ -581,15 +572,15 @@ describe('watcher', function() {
581
572
) ;
582
573
} ) ;
583
574
584
- it ( 'should match a dotfolder if explicitly asked to' , function ( done ) {
575
+ it ( 'should match a dotfolder if explicitly asked to' , function ( done ) {
585
576
config . load (
586
577
{
587
578
watch : [ 'test/fixtures/.dotfolder' ] ,
588
579
} ,
589
- function ( config ) {
580
+ function ( config ) {
590
581
return watch
591
582
. watch ( )
592
- . then ( function ( files ) {
583
+ . then ( function ( files ) {
593
584
assert . deepEqual (
594
585
files . length ,
595
586
3 ,
@@ -602,33 +593,23 @@ describe('watcher', function() {
602
593
) ;
603
594
} ) ;
604
595
605
- it ( 'should watch relative paths' , function ( ) {
606
- const monitor = match . rulesToMonitor ( [ './http.js' ] , [ ] , {
596
+ it ( 'should watch relative paths' , function ( ) {
597
+ const monitor = match . rulesToMonitor ( [ './http.js' ] , [ ] , {
607
598
dirs : [ ] ,
608
599
} ) ;
609
600
610
- var matched = match (
611
- [ 'http.js' ] ,
612
- monitor ,
613
- 'js,mjs,json'
614
- ) ;
601
+ var matched = match ( [ 'http.js' ] , monitor , 'js,mjs,json' ) ;
615
602
assert ( matched . result . length === 1 , 'found match ' + matched . results ) ;
616
603
} ) ;
617
604
618
-
619
605
it ( 'should ignore relative directories' , ( ) => {
620
- const monitor = match . rulesToMonitor ( [ ] , [
621
- "node_modules/*" ,
622
- "**/logs/*"
623
- ] )
624
-
625
- var matched = match (
626
- [ 'logs/a' ] ,
627
- monitor ,
628
- 'js,mjs,json'
629
- ) ;
606
+ const monitor = match . rulesToMonitor ( [ ] , [ 'node_modules/*' , '**/logs/*' ] ) ;
630
607
631
- assert ( matched . ignored === 1 && matched . result . length === 0 , JSON . stringify ( matched ) ) ;
608
+ var matched = match ( [ 'logs/a' ] , monitor , 'js,mjs,json' ) ;
632
609
633
- } )
610
+ assert (
611
+ matched . ignored === 1 && matched . result . length === 0 ,
612
+ JSON . stringify ( matched )
613
+ ) ;
614
+ } ) ;
634
615
} ) ;
0 commit comments