Skip to content

Commit

Permalink
Merge pull request #8211 from meeseeksmachine/auto-backport-of-pr-821…
Browse files Browse the repository at this point in the history
…0-on-1.2.x

Backport PR #8210 on branch 1.2.x (Clean up file watching)
  • Loading branch information
Steven Silvester committed Apr 11, 2020
2 parents ce517f5 + f206d35 commit 7087a82
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions dev_mode/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,6 @@ Object.keys(jlab.linkedPackages).forEach(function(name) {
watched[name] = plib.dirname(localPkgPath);
});

/**
* Sync a local path to a linked package path if they are files and differ.
*/
function maybeSync(localPath, name, rest) {
const stats = fs.statSync(localPath);
if (!stats.isFile(localPath)) {
return;
}
const source = fs.realpathSync(plib.join(jlab.linkedPackages[name], rest));
if (source === fs.realpathSync(localPath)) {
return;
}
fs.watchFile(source, { interval: 500 }, function(curr) {
if (!curr || curr.nlink === 0) {
return;
}
try {
fs.copySync(source, localPath);
} catch (err) {
console.error(err);
}
});
}

/**
* A filter function set up to exclude all files that are not
* in a package contained by the Jupyterlab repo. Used to ignore
Expand All @@ -107,7 +83,6 @@ function ignored(path) {
const rest = path.slice(rootPath.length);
if (rest.indexOf('node_modules') === -1) {
ignore = false;
maybeSync(path, name, rest);
}
return true;
});
Expand Down Expand Up @@ -210,7 +185,8 @@ module.exports = [
]
},
watchOptions: {
poll: 333
poll: 500,
aggregateTimeout: 1000
},
node: {
fs: 'empty'
Expand Down

0 comments on commit 7087a82

Please sign in to comment.