mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
fix: ignore ./<path> on cwd (#1787)
Fixes: #1784 This fixes the watch/ignore rules where the config is ignoring the relative local path of ./ - this fix was in place for the positive (watch) test but not patched for the negative (ignore).
This commit is contained in:
@@ -157,6 +157,12 @@ function match(files, monitor, ext) {
|
|||||||
if (s.indexOf('!' + cwd) === 0) {
|
if (s.indexOf('!' + cwd) === 0) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if it starts with a period, then let's get the relative path
|
||||||
|
if (s.indexOf('!.') === 0) {
|
||||||
|
return '!' + path.resolve(cwd, s.substring(1));
|
||||||
|
}
|
||||||
|
|
||||||
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
|
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,12 +201,13 @@ function match(files, monitor, ext) {
|
|||||||
for (var i = 0; i < rules.length; i++) {
|
for (var i = 0; i < rules.length; i++) {
|
||||||
if (rules[i].slice(0, 1) === '!') {
|
if (rules[i].slice(0, 1) === '!') {
|
||||||
if (!minimatch(file, rules[i], minimatchOpts)) {
|
if (!minimatch(file, rules[i], minimatchOpts)) {
|
||||||
|
debug('ignored', file, 'rule:', rules[i]);
|
||||||
ignored++;
|
ignored++;
|
||||||
matched = true;
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug('match', file, minimatch(file, rules[i], minimatchOpts));
|
debug('matched', file, 'rule:', rules[i]);
|
||||||
if (minimatch(file, rules[i], minimatchOpts)) {
|
if (minimatch(file, rules[i], minimatchOpts)) {
|
||||||
watched++;
|
watched++;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,50 @@ describe('match', function() {
|
|||||||
'!*.coffee',
|
'!*.coffee',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
it('should resolve ./ in positive match', () => {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const res = match(
|
||||||
|
[cwd + '/app.nodemon'],
|
||||||
|
[
|
||||||
|
'./*.nodemon',
|
||||||
|
'!**/dir/*.nodemon',
|
||||||
|
],
|
||||||
|
'js,mjs,json,nodemon'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(res.result.length, 1, JSON.stringify(res));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve ./ in positive match (miss test)', () => {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const res = match(
|
||||||
|
[cwd + '/dir/app.nodemon'],
|
||||||
|
[
|
||||||
|
'./*.nodemon',
|
||||||
|
'!**/dir/*.nodemon',
|
||||||
|
],
|
||||||
|
'js,mjs,json,nodemon'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(res.result.length, 0, JSON.stringify(res));
|
||||||
|
assert.equal(res.ignored, 1, JSON.stringify(res));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should resolve ./ in negative match (hit test)', () => {
|
||||||
|
const cwd = process.cwd();
|
||||||
|
const res = match(
|
||||||
|
[cwd + '/app.nodemon'],
|
||||||
|
[
|
||||||
|
'!./*.nodemon',
|
||||||
|
'**/dir/*.nodemon',
|
||||||
|
],
|
||||||
|
'js,mjs,json,nodemon'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(res.result.length, 0, JSON.stringify(res));
|
||||||
|
assert.equal(res.ignored, 1, JSON.stringify(res));
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle lots of **s!', () => {
|
it('should handle lots of **s!', () => {
|
||||||
const res = match(
|
const res = match(
|
||||||
['test/fixtures/app.js'],
|
['test/fixtures/app.js'],
|
||||||
|
|||||||
Reference in New Issue
Block a user