1
1
'use strict' ;
2
- /*global describe:true, it: true, afterEach: true, beforeEach: true, after:true */
3
- var load = require ( '../../lib/config/load' ) ,
4
- cli = require ( '../../lib/cli/' ) ,
5
- path = require ( 'path' ) ,
6
- testUtils = require ( '../utils' ) ,
7
- utils = require ( '../../lib/utils' ) ,
8
- rules = require ( '../../lib/rules' ) ,
9
- exec = require ( '../../lib/config/exec' ) ,
10
- nodemon = require ( '../../lib/nodemon' ) ,
11
- command = require ( '../../lib/config/command' ) ,
12
- assert = require ( 'assert' ) ;
2
+ /*global describe, it, afterEach, beforeEach, after */
3
+ var load = require ( '../../lib/config/load' ) ;
4
+ var defaults = require ( '../../lib/config/defaults' ) ;
5
+ var cli = require ( '../../lib/cli/' ) ;
6
+ var path = require ( 'path' ) ;
7
+ var testUtils = require ( '../utils' ) ;
8
+ var utils = require ( '../../lib/utils' ) ;
9
+ var rules = require ( '../../lib/rules' ) ;
10
+ var exec = require ( '../../lib/config/exec' ) ;
11
+ var nodemon = require ( '../../lib/nodemon' ) ;
12
+ var command = require ( '../../lib/config/command' ) ;
13
+ var assert = require ( 'assert' ) ;
13
14
14
15
function asCLI ( cmd ) {
15
- return ( 'node nodemon ' + ( cmd || '' ) ) . trim ( ) ;
16
+ return ( 'node nodemon ' + ( cmd || '' ) ) . trim ( ) ;
16
17
}
17
18
18
19
function commandToString ( command ) {
@@ -125,7 +126,7 @@ describe('config load', function () {
125
126
options = { } ;
126
127
load ( settings , options , config , function ( config ) {
127
128
removeRegExp ( config ) ;
128
- assert . deepEqual ( config . ignore , [ 'one' ] , 'ignore is "one": ' + config . ignore ) ;
129
+ assert ( config . ignore . indexOf ( 'one' ) !== - 1 , ' "one" is ignored : ' + config . ignore ) ;
129
130
assert . deepEqual ( config . watch , [ 'one' ] , 'watch is "one": ' + config . watch ) ;
130
131
done ( ) ;
131
132
} ) ;
@@ -164,20 +165,49 @@ describe('config load', function () {
164
165
process . chdir ( path . resolve ( pwd , 'test/fixtures/legacy' ) ) ;
165
166
utils . home = path . resolve ( pwd , 'test/fixtures/legacy' ) ;
166
167
167
- var settings = { 'script' : './index.js' ,
168
- 'verbose' : true ,
169
- 'ignore' : [ '*/artic/templates/*' ] ,
170
- 'ext' : 'js coffee json' ,
171
- 'watch' : [ '*.coffee' ] ,
172
- 'execMap' : { 'js' : 'node --harmony' , 'coffee' : 'node --harmony' , }
173
- } ,
174
- config = { } ,
175
- options = { } ;
168
+ var settings = {
169
+ script : './index.js' ,
170
+ verbose : true ,
171
+ ignore : [ '*/artic/templates/*' ] ,
172
+ ext : 'js coffee json' ,
173
+ watch : [ '*.coffee' ] ,
174
+ execMap : { js : 'node --harmony' , coffee : 'node --harmony' , } ,
175
+ } ;
176
+ var config = { } ;
177
+ var options = { } ;
176
178
177
179
load ( settings , options , config , function ( config ) {
178
180
var cmd = commandToString ( command ( config ) ) ;
179
181
assert ( cmd === 'node --harmony ./index.js' , 'cmd is: ' + cmd ) ;
180
182
done ( ) ;
181
183
} ) ;
182
184
} ) ;
185
+
186
+ it ( 'should merge ignore rules' , function ( done ) {
187
+ load ( {
188
+ ignore : [ '*/artic/templates/*' , 'views/*' ] ,
189
+ } , { } , { } , function ( config ) {
190
+ assert . equal ( config . ignore . length , defaults . ignore . length + 2 ) ;
191
+ done ( ) ;
192
+ } ) ;
193
+ } ) ;
194
+
195
+ it ( 'should merge ignore rules even when strings' , function ( done ) {
196
+ load ( {
197
+ ignore : 'public' ,
198
+ } , { } , { } , function ( config ) {
199
+ assert . equal ( config . ignore . length , defaults . ignore . length + 1 ) ;
200
+ done ( ) ;
201
+ } ) ;
202
+ } ) ;
203
+
204
+ it ( 'should allow user to override root ignore rules' , function ( done ) {
205
+ load ( {
206
+ ignore : 'public' ,
207
+ ignoreRoot : [ ] ,
208
+ } , { } , { } , function ( config ) {
209
+ assert . equal ( config . ignore . length , 1 ) ;
210
+ done ( ) ;
211
+ } ) ;
212
+ } ) ;
183
213
} ) ;
0 commit comments