Skip to content

Commit

Permalink
fix: node_modules watched off relative path (#1328)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
remy committed May 5, 2018
1 parent 9bbc219 commit 97f8d0a
Show file tree
Hide file tree
Showing 6 changed files with 1,371 additions and 1,846 deletions.
2 changes: 1 addition & 1 deletion lib/config/index.js
Expand Up @@ -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);
});
});
};
Expand Down
12 changes: 8 additions & 4 deletions lib/monitor/watch.js
Expand Up @@ -61,7 +61,6 @@ function watch() {

var watchOptions = {
ignorePermissionErrors: true,
cwd: process.cwd(), // dir,
ignored: ignored,
persistent: true,
usePolling: config.options.legacyWatch || false,
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions lib/utils/log.js
Expand Up @@ -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?
Expand Down

0 comments on commit 97f8d0a

Please sign in to comment.