Skip to content

Commit

Permalink
Merge pull request #8396 from blink1073/fix-watch-mode-1.2.x
Browse files Browse the repository at this point in the history
[1.2.x] Fix watch mode and add CI Test
  • Loading branch information
Steven Silvester committed May 8, 2020
2 parents 220e420 + 9ec00c2 commit a9e2ee9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
27 changes: 27 additions & 0 deletions dev_mode/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,32 @@ 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.
* This is used by `jupyter lab --watch` to synchronize linked packages
* and has no effect in `jupyter lab --dev-mode --watch`.
*/
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 @@ -83,6 +109,7 @@ 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
5 changes: 4 additions & 1 deletion jupyterlab/browser_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
{'BrowserApp': {'dev_mode': True}},
"Start the app in dev mode."
)

test_flags['watch'] = (
{'BrowserApp': {'watch': True}},
"Start the app in watch mode."
)

test_aliases = dict(aliases)
test_aliases['app-dir'] = 'BrowserApp.app_dir'
Expand Down
2 changes: 1 addition & 1 deletion jupyterlab/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def load_jupyter_server_extension(nbapp):
logger.info(DEV_NOTE)

# Make sure the app dir exists.
else:
elif not watch_mode:
msgs = ensure_app(app_dir)
if msgs:
[logger.error(msg) for msg in msgs]
Expand Down
4 changes: 4 additions & 0 deletions scripts/ci_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ if [[ $GROUP == usage ]]; then
# Make sure the deprecated `selenium_check` command still works
python -m jupyterlab.selenium_check

# Make sure we can run watch mode with no built application
jupyter lab clean
python -m jupyterlab.browser_check --watch

# Make sure we can non-dev install.
pip install virtualenv
virtualenv -p $(which python3) test_install
Expand Down

0 comments on commit a9e2ee9

Please sign in to comment.