Skip to content

Commit

Permalink
fix: defined diretory watching
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Dec 20, 2017
1 parent d15cf68 commit 1e2516d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/monitor/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function match(files, monitor, ext) {
// sort the rules by highest specificity (based on number of slashes)
// ignore rules (!) get sorted highest as they take precedent
// TODO actually check separator rules work on windows
const cwd = process.cwd();
var rules = monitor.sort(function (a, b) {
var r = b.split(path.sep).length - a.split(path.sep).length;
var aIsIgnore = a.slice(0, 1) === '!';
Expand All @@ -154,8 +155,13 @@ function match(files, monitor, ext) {
}

if (s.slice(0, 2) === '..') {
return path.resolve(process.cwd(), s);
return path.resolve(cwd, s);
}

if (s.indexOf(cwd) === 0) {
return s;
}

return '**' + (prefix !== path.sep ? path.sep : '') + s;
});

Expand All @@ -172,6 +178,8 @@ function match(files, monitor, ext) {
}

files.forEach(function (file) {
file = path.resolve(cwd, file);

var matched = false;
for (var i = 0; i < rules.length; i++) {
if (rules[i].slice(0, 1) === '!') {
Expand Down Expand Up @@ -205,6 +213,8 @@ function match(files, monitor, ext) {
}
matched = true;
break;
} else {
// utils.log.detail('no match: ' + rules[i], file);
}
}
}
Expand Down

0 comments on commit 1e2516d

Please sign in to comment.