mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
fix: node_modules watched off relative path (#1328)
* chore: bump chokidar to latest * test: fix weird output on restart filename * test: skip old broken test * fix: node_modules watched off relative path Fixes #1294 Fixes #1305 (though couldn't confirm - just looks very similar) I've gone back and forth on this Chokidar option `cwd` and in this fix I've removed it from the config. I've checked the issues that were raised that caused me to add the option, and they still appear to pass in the tests, so I believe it's okay. However, it _might_ come back in - just a note for Future @remy.
This commit is contained in:
@@ -83,7 +83,7 @@ config.load = function (settings, ready) {
|
||||
}).catch(e => {
|
||||
// this doesn't help testing, but does give exposure on syntax errors
|
||||
console.error(e.stack);
|
||||
throw e;
|
||||
setTimeout(() => { throw e; }, 0);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -61,7 +61,6 @@ function watch() {
|
||||
|
||||
var watchOptions = {
|
||||
ignorePermissionErrors: true,
|
||||
cwd: process.cwd(), // dir,
|
||||
ignored: ignored,
|
||||
persistent: true,
|
||||
usePolling: config.options.legacyWatch || false,
|
||||
@@ -135,18 +134,23 @@ function filterAndRestart(files) {
|
||||
files = [files];
|
||||
}
|
||||
if (files.length) {
|
||||
var cwd = this.options ? this.options.cwd : process.cwd();
|
||||
var cwd = process.cwd();
|
||||
if (this.options && this.options.cwd) {
|
||||
cwd = this.options.cwd;
|
||||
}
|
||||
|
||||
utils.log.detail(
|
||||
'files triggering change check: ' +
|
||||
files
|
||||
.map(function (file) {
|
||||
return path.relative(cwd, file);
|
||||
const res = path.relative(cwd, file);
|
||||
return res;
|
||||
})
|
||||
.join(', ')
|
||||
);
|
||||
|
||||
files = files.map(file => {
|
||||
return path.relative(process.cwd(), path.join(cwd, file));
|
||||
return path.relative(process.cwd(), path.relative(cwd, file));
|
||||
});
|
||||
|
||||
if (utils.isWindows) {
|
||||
|
||||
@@ -19,8 +19,11 @@ function log(type, text) {
|
||||
msg = colour(coding[type], msg);
|
||||
}
|
||||
|
||||
// always push the message through our bus
|
||||
bus.emit('log', { type: type, message: text, colour: msg });
|
||||
// always push the message through our bus, using nextTick
|
||||
// to help testing and get _out of_ promises.
|
||||
process.nextTick(() => {
|
||||
bus.emit('log', { type: type, message: text, colour: msg });
|
||||
});
|
||||
|
||||
// but if we're running on the command line, also echo out
|
||||
// question: should we actually just consume our own events?
|
||||
|
||||
3185
package-lock.json
generated
3185
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -37,4 +37,20 @@ describe('watch count', function () {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should ignore node_modules from any dir', function (done) {
|
||||
process.chdir('test/fixtures/watch-count/lib');
|
||||
nodemon({ script: appjs, verbose: true, watch: '..' }).on('start', function () {
|
||||
setTimeout(function () {
|
||||
nodemon.once('exit', done).emit('quit');
|
||||
}, 200);
|
||||
}).on('log', function (data) {
|
||||
var match = null;
|
||||
var count = 0;
|
||||
if (match = data.message.match(watchRe)) {
|
||||
count = match[1].replace(',', '') * 1;
|
||||
assert(count === 6, 'Watching ' + count + ' files, expecting 6.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -140,7 +140,8 @@ describe('when nodemon runs (2)', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not run command on startup if runOnChangeOnly is true',
|
||||
// FIXME this test was never working properly
|
||||
it.skip('should not run command on startup if runOnChangeOnly is true',
|
||||
function (done) {
|
||||
fs.writeFileSync(tmp, 'console.log("testing 1 2 3")');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user