fix: allow watching relative path files (#1385)

Fixes #1355
This commit is contained in:
Remy Sharp
2018-07-10 18:39:53 +01:00
committed by GitHub
parent ec76cadcac
commit 9d1a63c6a6
3 changed files with 17 additions and 2 deletions

View File

@@ -5,7 +5,7 @@
--config file ............ alternate nodemon.json config file to use
-e, --ext ................ extensions to look for, ie. js,jade,hbs.
-x, --exec app ........... execute script with "app", ie. -x "python -v".
-w, --watch dir........... watch directory "dir" or files. use once for
-w, --watch path.......... watch directory "path" or files. use once for
each directory or file to watch.
-i, --ignore ............. ignore specific files or directories.
-V, --verbose ............ show detail on what is causing restarts.

View File

@@ -160,7 +160,8 @@ function match(files, monitor, ext) {
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
}
if (s.slice(0, 2) === '..') {
// if it starts with a period, then let's get the relative path
if (s.indexOf('.') === 0) {
return path.resolve(cwd, s);
}

View File

@@ -557,4 +557,18 @@ describe('watcher', function() {
}
);
});
it('should watch relative paths', function() {
const monitor = match.rulesToMonitor([ './http.js' ], [], {
dirs: [],
});
var matched = match(
['http.js'],
monitor,
'js,mjs,json'
);
assert(matched.result.length === 1, 'found match ' + matched.results);
});
});