Skip to content

Commit 7881f05

Browse files
committedJul 7, 2023
chore: remove legacy .nodemon support
As part of a semi-clean up from bump to 3.x
1 parent 04302b8 commit 7881f05

File tree

6 files changed

+1447
-8866
lines changed

6 files changed

+1447
-8866
lines changed
 

‎.prettierrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

‎faq.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ For example, on `lib/app.js` being changed:
238238

239239
## My .nodemonignore is being ignored
240240

241+
_The legacy `.nodemonignore` was dropped in nodemon@3_
242+
241243
The new `nodemon.json` supersedes the `.nodemonignore` file, so if you have both, the `.nodemonignore` is not used at all.
242244

243245
Note that if you have a `nodemon.json` in your `$HOME` path, then this will also supersede the old ignore file (and the _legacy_ format config is ignored).
@@ -336,7 +338,7 @@ nodemon --ext '*' --watch public --exec 'python -m SimpleHTTPServer'
336338

337339
Based on [this issue](https://github.com/remy/nodemon/issues/2056).
338340

339-
Sometimes when using the `--inspect` flag, nodemon will try to start the a process before the old process is finished.
341+
Sometimes when using the `--inspect` flag, nodemon will try to start the a process before the old process is finished.
340342

341343
This will cause an error trying to up the new process because of the debugger service:
342344

‎lib/config/load.js

+28-63
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ var existsSync = fs.existsSync || path.existsSync;
1616
function findAppScript() {
1717
// nodemon has been run alone, so try to read the package file
1818
// or try to read the index.js file
19-
20-
var pkg = existsSync(path.join(process.cwd(), 'package.json')) && require(path.join(process.cwd(), 'package.json'));
19+
20+
var pkg =
21+
existsSync(path.join(process.cwd(), 'package.json')) &&
22+
require(path.join(process.cwd(), 'package.json'));
2123
if ((!pkg || pkg.main == undefined) && existsSync('./index.js')) {
2224
return 'index.js';
2325
}
@@ -64,7 +66,6 @@ function load(settings, options, config, callback) {
6466
options.ignore = defaults.ignore.concat(options.ignore);
6567
}
6668

67-
6869
// add in any missing defaults
6970
options = utils.merge(options, defaults);
7071

@@ -76,11 +77,14 @@ function load(settings, options, config, callback) {
7677
}
7778
// if the script is found as a result of not being on the command
7879
// line, then we move any of the pre double-dash args in execArgs
79-
const n = options.scriptPosition === null ?
80-
options.args.length : options.scriptPosition;
81-
82-
options.execArgs = (options.execArgs || [])
83-
.concat(options.args.splice(0, n));
80+
const n =
81+
options.scriptPosition === null
82+
? options.args.length
83+
: options.scriptPosition;
84+
85+
options.execArgs = (options.execArgs || []).concat(
86+
options.args.splice(0, n)
87+
);
8488
options.scriptPosition = null;
8589

8690
options.script = found;
@@ -104,53 +108,11 @@ function load(settings, options, config, callback) {
104108
normaliseRules(options, callback);
105109
};
106110

107-
// if we didn't pick up a nodemon.json file & there's no cli ignores
108-
// then try loading an old style .nodemonignore file
109-
if (config.loaded.length === 0) {
110-
var legacy = loadLegacyIgnore.bind(null, options, config, ready);
111-
112-
// first try .nodemonignore, if that doesn't exist, try nodemon-ignore
113-
return legacy('.nodemonignore', function () {
114-
legacy('nodemon-ignore', function (options) {
115-
ready(options);
116-
});
117-
});
118-
}
119-
120111
ready(options);
121112
});
122113
});
123114
}
124115

125-
/**
126-
* Loads the old style nodemonignore files which is a list of patterns
127-
* in a file to ignore
128-
*
129-
* @param {Object} options nodemon user options
130-
* @param {Function} success
131-
* @param {String} filename ignore file (.nodemonignore or nodemon-ignore)
132-
* @param {Function} fail (optional) failure callback
133-
*/
134-
function loadLegacyIgnore(options, config, success, filename, fail) {
135-
var ignoreFile = path.join(process.cwd(), filename);
136-
137-
exists(ignoreFile, function (exists) {
138-
if (exists) {
139-
config.loaded.push(ignoreFile);
140-
return parse(ignoreFile, function (error, rules) {
141-
options.ignore = rules.raw;
142-
success(options);
143-
});
144-
}
145-
146-
if (fail) {
147-
fail(options);
148-
} else {
149-
success(options);
150-
}
151-
});
152-
}
153-
154116
function normaliseRules(options, ready) {
155117
// convert ignore and watch options to rules/regexp
156118
rules.watch.add(options.watch);
@@ -172,7 +134,7 @@ function normaliseRules(options, ready) {
172134
*/
173135
function loadFile(options, config, dir, ready) {
174136
if (!ready) {
175-
ready = function () { };
137+
ready = function () {};
176138
}
177139

178140
var callback = function (settings) {
@@ -224,29 +186,32 @@ function loadFile(options, config, dir, ready) {
224186

225187
function loadPackageJSON(config, ready) {
226188
if (!ready) {
227-
ready = () => { };
189+
ready = () => {};
228190
}
229191

230192
const dir = process.cwd();
231193
const filename = path.join(dir, 'package.json');
232194
const packageLoadOptions = { configFile: filename };
233-
return loadFile(packageLoadOptions, config, dir, settings => {
195+
return loadFile(packageLoadOptions, config, dir, (settings) => {
234196
ready(settings.nodemonConfig || {});
235197
});
236198
}
237199

238200
function mutateExecOptions(options) {
239201
// work out the execOptions based on the final config we have
240-
options.execOptions = exec({
241-
script: options.script,
242-
exec: options.exec,
243-
args: options.args,
244-
scriptPosition: options.scriptPosition,
245-
nodeArgs: options.nodeArgs,
246-
execArgs: options.execArgs,
247-
ext: options.ext,
248-
env: options.env,
249-
}, options.execMap);
202+
options.execOptions = exec(
203+
{
204+
script: options.script,
205+
exec: options.exec,
206+
args: options.args,
207+
scriptPosition: options.scriptPosition,
208+
nodeArgs: options.nodeArgs,
209+
execArgs: options.execArgs,
210+
ext: options.ext,
211+
env: options.env,
212+
},
213+
options.execMap
214+
);
250215

251216
// clean up values that we don't need at the top level
252217
delete options.scriptPosition;

‎package-lock.json

+1,191-8,628
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/config/load.test.js

+159-92
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ describe('config load', function () {
3131

3232
after(function (done) {
3333
// clean up just in case.
34-
nodemon.once('exit', function () {
35-
nodemon.reset(done);
36-
}).emit('quit');
34+
nodemon
35+
.once('exit', function () {
36+
nodemon.reset(done);
37+
})
38+
.emit('quit');
3739
});
3840

3941
function removeRegExp(options) {
@@ -44,51 +46,48 @@ describe('config load', function () {
4446
beforeEach(function () {
4547
// move to the fixtures directory to allow for config loading
4648
process.chdir(path.resolve(pwd, 'test/fixtures'));
47-
utils.home = path.resolve(pwd, ['test', 'fixtures', 'global'].join(path.sep));
49+
utils.home = path.resolve(
50+
pwd,
51+
['test', 'fixtures', 'global'].join(path.sep)
52+
);
4853

4954
rules.reset();
5055
nodemon.config.reset();
5156
});
5257

5358
it('should remove ignore defaults if user provides their own', function (done) {
54-
5559
nodemon({
5660
script: testUtils.appjs,
57-
verbose: true
58-
}).on('log', function (event) {
59-
// console.log(event.colour);
60-
}).on('start', function () {
61-
assert.ok(nodemon.config.options.ignore.indexOf('one') !== -1, 'Contains "one" path');
62-
assert.ok(nodemon.config.options.ignore.indexOf('three') !== -1, 'Contains "three" path');
63-
// note: we use the escaped format: \\.git
64-
assert.ok(nodemon.config.options.ignore.indexOf('\\.git') === -1, 'nodemon is not ignoring (default) .git');
65-
66-
nodemon.on('exit', function () {
67-
nodemon.reset(done);
61+
verbose: true,
62+
})
63+
.on('log', function (event) {
64+
// console.log(event.colour);
65+
})
66+
.on('start', function () {
67+
assert.ok(
68+
nodemon.config.options.ignore.indexOf('one') !== -1,
69+
'Contains "one" path'
70+
);
71+
assert.ok(
72+
nodemon.config.options.ignore.indexOf('three') !== -1,
73+
'Contains "three" path'
74+
);
75+
// note: we use the escaped format: \\.git
76+
assert.ok(
77+
nodemon.config.options.ignore.indexOf('\\.git') === -1,
78+
'nodemon is not ignoring (default) .git'
79+
);
80+
81+
nodemon.on('exit', function () {
82+
nodemon.reset(done);
83+
});
84+
85+
setTimeout(function () {
86+
nodemon.emit('quit');
87+
}, 1000);
6888
});
69-
70-
setTimeout(function () {
71-
nodemon.emit('quit');
72-
}, 1000);
73-
});
74-
});
75-
76-
it('should support old .nodemonignore', function (done) {
77-
// prevents our test from finding the nodemon.json files
78-
process.chdir(path.resolve(pwd, 'test/fixtures/legacy'));
79-
utils.home = path.resolve(pwd, 'test/fixtures/legacy');
80-
81-
var config = {},
82-
settings = {},
83-
options = {};
84-
85-
load(settings, options, config, function (config) {
86-
assert(config.ignore.length === 5, '5 rules found: ' + config.ignore);
87-
done();
88-
});
8989
});
9090

91-
9291
it('should read global config', function (done) {
9392
var config = {},
9493
settings = { quiet: true },
@@ -98,10 +97,12 @@ describe('config load', function () {
9897

9998
// ensure global mapping works too
10099
var options = exec({ script: 'template.pug' }, config.execMap);
101-
assert(options.exec === 'bin/pug template.pug --out /tmp', 'exec used, should be "bin/pug": ' + options.exec);
100+
assert(
101+
options.exec === 'bin/pug template.pug --out /tmp',
102+
'exec used, should be "bin/pug": ' + options.exec
103+
);
102104

103105
done();
104-
105106
});
106107
});
107108

@@ -124,15 +125,28 @@ describe('config load', function () {
124125
options = {};
125126
load(settings, options, config, function (config) {
126127
removeRegExp(config);
127-
assert.ok(config.ignore.indexOf('one') !== -1, 'ignore contains "one": ' + config.ignore);
128-
assert.ok(config.ignore.indexOf('three') !== -1, 'ignore contains "three": ' + config.ignore);
129-
assert.deepEqual(config.watch, ['four'], 'watch is "four": ' + config.watch);
128+
assert.ok(
129+
config.ignore.indexOf('one') !== -1,
130+
'ignore contains "one": ' + config.ignore
131+
);
132+
assert.ok(
133+
config.ignore.indexOf('three') !== -1,
134+
'ignore contains "three": ' + config.ignore
135+
);
136+
assert.deepEqual(
137+
config.watch,
138+
['four'],
139+
'watch is "four": ' + config.watch
140+
);
130141
done();
131142
});
132143
});
133144

134145
it('should give local files preference over package.json config', function (done) {
135-
var dir = path.resolve(pwd, 'test/fixtures/packages/nodemon-settings-and-package-json-settings');
146+
var dir = path.resolve(
147+
pwd,
148+
'test/fixtures/packages/nodemon-settings-and-package-json-settings'
149+
);
136150
process.chdir(dir);
137151

138152
var config = {},
@@ -154,9 +168,19 @@ describe('config load', function () {
154168
load(settings, options, config, function (config) {
155169
removeRegExp(config);
156170
assert.deepEqual(config.exec, 'foo', 'exec is "foo": ' + config.exec);
157-
assert.ok(config.ignore.indexOf('one') !== -1, 'ignore contains "one": ' + config.ignore);
158-
assert.ok(config.ignore.indexOf('three') !== -1, 'ignore contains "three": ' + config.ignore);
159-
assert.deepEqual(config.watch, ['four'], 'watch is "four": ' + config.watch);
171+
assert.ok(
172+
config.ignore.indexOf('one') !== -1,
173+
'ignore contains "one": ' + config.ignore
174+
);
175+
assert.ok(
176+
config.ignore.indexOf('three') !== -1,
177+
'ignore contains "three": ' + config.ignore
178+
);
179+
assert.deepEqual(
180+
config.watch,
181+
['four'],
182+
'watch is "four": ' + config.watch
183+
);
160184
done();
161185
});
162186
});
@@ -167,8 +191,15 @@ describe('config load', function () {
167191
options = {};
168192
load(settings, options, config, function (config) {
169193
removeRegExp(config);
170-
assert(config.ignore.indexOf('one') !== -1, '"one" is ignored: ' + config.ignore);
171-
assert.deepEqual(config.watch, ['one'], 'watch is "one": ' + config.watch);
194+
assert(
195+
config.ignore.indexOf('one') !== -1,
196+
'"one" is ignored: ' + config.ignore
197+
);
198+
assert.deepEqual(
199+
config.watch,
200+
['one'],
201+
'watch is "one": ' + config.watch
202+
);
172203
done();
173204
});
174205
});
@@ -181,7 +212,11 @@ describe('config load', function () {
181212
settings = { exec: 'foo-user', quiet: true },
182213
options = {};
183214
load(settings, options, config, function (config) {
184-
assert.deepEqual(config.exec, 'foo-user', 'exec is "foo-user": ' + config.exec);
215+
assert.deepEqual(
216+
config.exec,
217+
'foo-user',
218+
'exec is "foo-user": ' + config.exec
219+
);
185220
done();
186221
});
187222
});
@@ -191,7 +226,7 @@ describe('config load', function () {
191226
process.chdir(dir);
192227

193228
var config = {},
194-
settings = { 'script': './index.js', },
229+
settings = { script: './index.js' },
195230
options = {};
196231

197232
load(settings, options, config, function (config) {
@@ -201,7 +236,10 @@ describe('config load', function () {
201236
});
202237

203238
it('should give package.json specified exec config over package.scripts.start', function (done) {
204-
var dir = path.resolve(pwd, 'test/fixtures/packages/start-and-package-json-settings');
239+
var dir = path.resolve(
240+
pwd,
241+
'test/fixtures/packages/start-and-package-json-settings'
242+
);
205243
process.chdir(dir);
206244

207245
var config = {},
@@ -239,7 +277,7 @@ describe('config load', function () {
239277
ignore: ['*/artic/templates/*'],
240278
ext: 'js coffee json',
241279
watch: ['*.coffee'],
242-
execMap: { js: 'node --harmony', coffee: 'node --harmony', },
280+
execMap: { js: 'node --harmony', coffee: 'node --harmony' },
243281
};
244282
var config = {};
245283
var options = {};
@@ -252,56 +290,85 @@ describe('config load', function () {
252290
});
253291

254292
it('should merge ignore rules', function (done) {
255-
load({
256-
ignore: ['*/artic/templates/*', 'views/*'],
257-
}, {}, {}, function (config) {
258-
assert.equal(config.ignore.length, defaults.ignoreRoot.length + 2);
259-
done();
260-
});
293+
load(
294+
{
295+
ignore: ['*/artic/templates/*', 'views/*'],
296+
},
297+
{},
298+
{},
299+
function (config) {
300+
assert.equal(config.ignore.length, defaults.ignoreRoot.length + 2);
301+
done();
302+
}
303+
);
261304
});
262305

263306
it('should allow user to override ignoreRoot', function (done) {
264-
load({
265-
ignore: ['*/artic/templates/*', 'views/*'],
266-
ignoreRoot: ['.git'],
267-
}, {}, {}, function (config) {
268-
assert.equal(config.ignore.length, 3);
269-
done();
270-
});
307+
load(
308+
{
309+
ignore: ['*/artic/templates/*', 'views/*'],
310+
ignoreRoot: ['.git'],
311+
},
312+
{},
313+
{},
314+
function (config) {
315+
assert.equal(config.ignore.length, 3);
316+
done();
317+
}
318+
);
271319
});
272320

273321
it('should merge ignore rules even when strings', function (done) {
274-
load({
275-
ignore: 'public',
276-
}, {}, {}, function (config) {
277-
assert.equal(config.ignore.length, defaults.ignoreRoot.length + 1);
278-
done();
279-
});
322+
load(
323+
{
324+
ignore: 'public',
325+
},
326+
{},
327+
{},
328+
function (config) {
329+
assert.equal(config.ignore.length, defaults.ignoreRoot.length + 1);
330+
done();
331+
}
332+
);
280333
});
281334

282335
it('should allow user to override root ignore rules', function (done) {
283-
load({
284-
ignore: 'public',
285-
ignoreRoot: [],
286-
}, {}, {}, function (config) {
287-
assert.equal(config.ignore.length, 1);
288-
done();
289-
});
336+
load(
337+
{
338+
ignore: 'public',
339+
ignoreRoot: [],
340+
},
341+
{},
342+
{},
343+
function (config) {
344+
assert.equal(config.ignore.length, 1);
345+
done();
346+
}
347+
);
290348
});
291349

292-
it('should allow user to set execArgs', done => {
293-
const execArgs = ['--inspect']
294-
load({
295-
execArgs,
296-
}, {}, {}, config => {
297-
assert.deepEqual(config.execArgs, execArgs);
298-
done();
299-
})
350+
it('should allow user to set execArgs', (done) => {
351+
const execArgs = ['--inspect'];
352+
load(
353+
{
354+
execArgs,
355+
},
356+
{},
357+
{},
358+
(config) => {
359+
assert.deepEqual(config.execArgs, execArgs);
360+
done();
361+
}
362+
);
300363
});
301364

302-
it('should support pkg.main and keep user args on args', done => {
365+
it('should support pkg.main and keep user args on args', (done) => {
303366
process.chdir(path.resolve(pwd, 'test/fixtures/packages/main-and-start'));
304-
const settings = { scriptPosition: 0, script: null, args: [ 'first', 'second' ] };
367+
const settings = {
368+
scriptPosition: 0,
369+
script: null,
370+
args: ['first', 'second'],
371+
};
305372
const options = { ignore: [], watch: [], monitor: [] };
306373
const config = {
307374
run: false,
@@ -311,13 +378,13 @@ describe('config load', function () {
311378
timeout: 1000,
312379
options: { ignore: [], watch: [], monitor: [] },
313380
lastStarted: 0,
314-
loaded: []
315-
}
381+
loaded: [],
382+
};
316383

317-
load(settings, options, config, res => {
384+
load(settings, options, config, (res) => {
318385
assert.deepEqual(res.execOptions.args, ['first', 'second']);
319386
done();
320-
})
387+
});
321388
});
322389

323390
it('should give package.main preference for script over index.js', function (done) {

‎test/monitor/match.test.js

+63-82
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var assert = require('assert'),
1111
watch = require('../../lib/monitor/watch'),
1212
merge = nodemonUtils.merge;
1313

14-
describe('match', function() {
14+
describe('match', function () {
1515
var monitor = [
1616
'!.git',
1717
'!node_modules/*',
@@ -26,10 +26,7 @@ describe('match', function() {
2626
const cwd = process.cwd();
2727
const res = match(
2828
[cwd + '/app.nodemon'],
29-
[
30-
'./*.nodemon',
31-
'!**/dir/*.nodemon',
32-
],
29+
['./*.nodemon', '!**/dir/*.nodemon'],
3330
'js,mjs,json,nodemon'
3431
);
3532

@@ -40,10 +37,7 @@ describe('match', function() {
4037
const cwd = process.cwd();
4138
const res = match(
4239
[cwd + '/dir/app.nodemon'],
43-
[
44-
'./*.nodemon',
45-
'!**/dir/*.nodemon',
46-
],
40+
['./*.nodemon', '!**/dir/*.nodemon'],
4741
'js,mjs,json,nodemon'
4842
);
4943

@@ -55,10 +49,7 @@ describe('match', function() {
5549
const cwd = process.cwd();
5650
const res = match(
5751
[cwd + '/app.nodemon'],
58-
[
59-
'!./*.nodemon',
60-
'**/dir/*.nodemon',
61-
],
52+
['!./*.nodemon', '**/dir/*.nodemon'],
6253
'js,mjs,json,nodemon'
6354
);
6455

@@ -83,7 +74,7 @@ describe('match', function() {
8374
assert.equal(res.result.length, 1, JSON.stringify(res));
8475
});
8576

86-
it('should match zero files', function() {
77+
it('should match zero files', function () {
8778
var files = [
8879
'views/server/remy.coffee',
8980
'random.coffee',
@@ -94,7 +85,7 @@ describe('match', function() {
9485
assert(results.result.length === 0, 'matched ' + results.result.length);
9586
});
9687

97-
it('should match one file', function() {
88+
it('should match one file', function () {
9889
var files = [
9990
'views/server/remy.js',
10091
'random.coffee',
@@ -105,7 +96,7 @@ describe('match', function() {
10596
assert(results.result.length === 1, 'matched ' + results.result.length);
10697
});
10798

108-
it('should match two files', function() {
99+
it('should match two files', function () {
109100
var files = [
110101
'views/server/test.js',
111102
'views/server/test2.js',
@@ -116,7 +107,7 @@ describe('match', function() {
116107
assert(results.result.length === 2, 'matched ' + results.result.length);
117108
});
118109

119-
it('should match one file', function() {
110+
it('should match one file', function () {
120111
var files = [
121112
'views/server/remy.js',
122113
'views/server/ignore.js',
@@ -129,7 +120,7 @@ describe('match', function() {
129120
assert(results.result.length === 1, 'matched ' + results.result.length);
130121
});
131122

132-
it('should apply *.js to any js file', function() {
123+
it('should apply *.js to any js file', function () {
133124
var files = [utils.appjs];
134125

135126
var result = match(files, ['*.*'], 'js');
@@ -139,7 +130,7 @@ describe('match', function() {
139130
assert(result.watched === files.length, 'a single file was matched');
140131
});
141132

142-
it('should ignore .coffee if watching *.js', function() {
133+
it('should ignore .coffee if watching *.js', function () {
143134
var files = [utils.appcoffee];
144135

145136
var result = match(files, ['*.*'], 'js');
@@ -151,12 +142,12 @@ describe('match', function() {
151142
);
152143
});
153144

154-
it('should match .coffee if watching *.js & *.coffee', function(done) {
145+
it('should match .coffee if watching *.js & *.coffee', function (done) {
155146
config.load(
156147
{
157148
ext: 'js coffee',
158149
},
159-
function(config) {
150+
function (config) {
160151
var files = [utils.appcoffee];
161152

162153
var result = match(
@@ -172,8 +163,8 @@ describe('match', function() {
172163
);
173164
});
174165

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) {
177168
var files = [utils.appjs, path.join(__dirname, '/.git/foo.js')];
178169

179170
var result = match(
@@ -190,13 +181,13 @@ describe('match', function() {
190181
});
191182
});
192183

193-
it('should ignore directories', function(done) {
184+
it('should ignore directories', function (done) {
194185
config.load(
195186
{
196187
ext: 'js',
197188
ignore: 'test/fixtures',
198189
},
199-
function(config) {
190+
function (config) {
200191
var files = [utils.appjs];
201192

202193
var result = match(
@@ -211,12 +202,12 @@ describe('match', function() {
211202
);
212203
});
213204

214-
it('should check all directories by default', function(done) {
205+
it('should check all directories by default', function (done) {
215206
config.load(
216207
{
217208
ext: 'js',
218209
},
219-
function(config) {
210+
function (config) {
220211
var files = [utils.appjs];
221212
var result = match(
222213
files,
@@ -229,7 +220,7 @@ describe('match', function() {
229220
);
230221
});
231222

232-
it('should support old .nodemonignore', function(done) {
223+
it('should support old .nodemonignore', function (done) {
233224
// prevents our test from finding the nodemon.json files
234225
var pwd = process.cwd(),
235226
old = nodemonUtils.home;
@@ -238,7 +229,7 @@ describe('match', function() {
238229
nodemonUtils.home = path.resolve(pwd, 'test/fixtures/legacy');
239230

240231
// 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) {
242233
var files = [utils.appjs];
243234
var result = match(
244235
files,
@@ -263,13 +254,13 @@ describe('match', function() {
263254
});
264255
});
265256

266-
it('should be specific about directories', function(done) {
257+
it('should be specific about directories', function (done) {
267258
config.load(
268259
{
269260
ext: 'js md pug',
270261
watch: ['lib'],
271262
},
272-
function(config) {
263+
function (config) {
273264
var files = [utils.appjs];
274265
var result = match(
275266
files,
@@ -283,12 +274,12 @@ describe('match', function() {
283274
);
284275
});
285276

286-
it('should not match coffee when monitoring just js', function(done) {
277+
it('should not match coffee when monitoring just js', function (done) {
287278
config.load(
288279
{
289280
script: utils.appjs,
290281
},
291-
function(config) {
282+
function (config) {
292283
var result = match(
293284
[utils.appcoffee],
294285
config.options.monitor,
@@ -301,7 +292,7 @@ describe('match', function() {
301292
);
302293
});
303294

304-
it('should ignore case when comparing paths on Windows', function() {
295+
it('should ignore case when comparing paths on Windows', function () {
305296
if (!nodemonUtils.isWindows) {
306297
return;
307298
}
@@ -310,8 +301,8 @@ describe('match', function() {
310301
});
311302
});
312303

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 () {
315306
var cwd = process.cwd();
316307
var dir = cwd + '/test/fixtures/configs';
317308
process.chdir(dir);
@@ -338,7 +329,7 @@ describe('validating files that cause restart', function() {
338329
);
339330
});
340331

341-
it('should allow *.js to match at the top level', function() {
332+
it('should allow *.js to match at the top level', function () {
342333
var filename = path.join('test', 'fixtures', 'configs', 'top-level.json');
343334
var config = JSON.parse(fs.readFileSync(filename));
344335
var settings = merge(config, defaults);
@@ -357,7 +348,7 @@ describe('validating files that cause restart', function() {
357348
assert(matched.result.length === 1, 'found match ' + matched.results);
358349
});
359350

360-
it('should allow for simple star rule: public/*', function() {
351+
it('should allow for simple star rule: public/*', function () {
361352
var filename = path.join('test', 'fixtures', 'configs', 'public-star.json');
362353
var config = JSON.parse(fs.readFileSync(filename));
363354
var settings = merge(config, defaults);
@@ -376,7 +367,7 @@ describe('validating files that cause restart', function() {
376367
assert(matched.result.length === 0, 'public/* ignored: ' + matched.results);
377368
});
378369

379-
it('should allow for relative paths with extensions', function() {
370+
it('should allow for relative paths with extensions', function () {
380371
var cwd = process.cwd();
381372
var dir = cwd + '/test/fixtures/configs';
382373
process.chdir(dir);
@@ -404,8 +395,8 @@ describe('validating files that cause restart', function() {
404395
});
405396
});
406397

407-
describe('match rule parser', function() {
408-
it('should support "--watch ."', function() {
398+
describe('match rule parser', function () {
399+
it('should support "--watch ."', function () {
409400
var config = { watch: '.' };
410401
var settings = merge(config, defaults);
411402
var script = 'index.js';
@@ -423,7 +414,7 @@ describe('match rule parser', function() {
423414
assert(matched.result.length === 1, 'no file matched');
424415
});
425416

426-
it('should support "--watch .*"', function() {
417+
it('should support "--watch .*"', function () {
427418
var config = { watch: '.*' };
428419
var settings = merge(config, defaults);
429420
var script = 'index.js';
@@ -441,7 +432,7 @@ describe('match rule parser', function() {
441432
assert(matched.result.length === 1, 'no file matched');
442433
});
443434

444-
it('should support "--watch <single file>"', function() {
435+
it('should support "--watch <single file>"', function () {
445436
var config = { watch: 'config.json' };
446437
var settings = merge(config, defaults);
447438

@@ -454,7 +445,7 @@ describe('match rule parser', function() {
454445
assert(matched.result.length === 1, 'no file matched');
455446
});
456447

457-
it('should support "--watch /some/path/*/config.json"', function() {
448+
it('should support "--watch /some/path/*/config.json"', function () {
458449
var config = { watch: '/*/config.json' };
459450
var settings = merge(config, defaults);
460451

@@ -467,7 +458,7 @@ describe('match rule parser', function() {
467458
assert(matched.result.length === 1, 'no file matched');
468459
});
469460

470-
it('should support "--watch *.*"', function() {
461+
it('should support "--watch *.*"', function () {
471462
var config = { watch: '*.*' };
472463
var settings = merge(config, defaults);
473464
var script = 'index.js';
@@ -485,7 +476,7 @@ describe('match rule parser', function() {
485476
assert(matched.result.length === 1, 'no file matched');
486477
});
487478

488-
it('should support "--watch .."', function() {
479+
it('should support "--watch .."', function () {
489480
// make sure we're in a deep enough directory
490481
var cwd = process.cwd();
491482
process.chdir('./test/fixtures/');
@@ -510,42 +501,42 @@ describe('match rule parser', function() {
510501
});
511502
});
512503

513-
describe('watcher', function() {
514-
afterEach(function(done) {
504+
describe('watcher', function () {
505+
afterEach(function (done) {
515506
config.reset();
516507
setTimeout(() => {
517508
watch.resetWatchers();
518509
done();
519510
}, 0);
520511
});
521512

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) {
523514
config.load(
524515
{
525516
watch: ['test/fixtures/app.js'],
526517
ignoreRoot: [],
527518
},
528-
function(config) {
519+
function (config) {
529520
return watch
530521
.watch()
531-
.then(function() {
522+
.then(function () {
532523
done();
533524
})
534525
.catch(done);
535526
}
536527
);
537528
});
538529

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) {
540531
config.load(
541532
{
542533
watch: ['test/fixtures/*'],
543534
},
544-
function(config) {
535+
function (config) {
545536
return watch
546537
.watch()
547-
.then(function(files) {
548-
var withDotfile = files.filter(function(file) {
538+
.then(function (files) {
539+
var withDotfile = files.filter(function (file) {
549540
return /test\/fixtures\/\.dotfile$/.test(file);
550541
});
551542
assert.deepEqual(
@@ -560,17 +551,17 @@ describe('watcher', function() {
560551
);
561552
});
562553

563-
it('should match a dotfile if explicitly asked to', function(done) {
554+
it('should match a dotfile if explicitly asked to', function (done) {
564555
config.load(
565556
{
566557
watch: ['test/fixtures/.dotfile'],
567558
},
568-
function(config) {
559+
function (config) {
569560
return watch
570561
.watch()
571-
.then(function(files) {
562+
.then(function (files) {
572563
assert.deepEqual(
573-
files.filter(f => f.endsWith('.dotfile')).length,
564+
files.filter((f) => f.endsWith('.dotfile')).length,
574565
1,
575566
'should contain .dotfile'
576567
);
@@ -581,15 +572,15 @@ describe('watcher', function() {
581572
);
582573
});
583574

584-
it('should match a dotfolder if explicitly asked to', function(done) {
575+
it('should match a dotfolder if explicitly asked to', function (done) {
585576
config.load(
586577
{
587578
watch: ['test/fixtures/.dotfolder'],
588579
},
589-
function(config) {
580+
function (config) {
590581
return watch
591582
.watch()
592-
.then(function(files) {
583+
.then(function (files) {
593584
assert.deepEqual(
594585
files.length,
595586
3,
@@ -602,33 +593,23 @@ describe('watcher', function() {
602593
);
603594
});
604595

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'], [], {
607598
dirs: [],
608599
});
609600

610-
var matched = match(
611-
['http.js'],
612-
monitor,
613-
'js,mjs,json'
614-
);
601+
var matched = match(['http.js'], monitor, 'js,mjs,json');
615602
assert(matched.result.length === 1, 'found match ' + matched.results);
616603
});
617604

618-
619605
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/*']);
630607

631-
assert(matched.ignored === 1 && matched.result.length === 0, JSON.stringify(matched));
608+
var matched = match(['logs/a'], monitor, 'js,mjs,json');
632609

633-
})
610+
assert(
611+
matched.ignored === 1 && matched.result.length === 0,
612+
JSON.stringify(matched)
613+
);
614+
});
634615
});

0 commit comments

Comments
 (0)
Please sign in to comment.