forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch-files.js
31 lines (26 loc) · 833 Bytes
/
watch-files.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var fs = require('fs-extra');
var path = require('path');
var watch = require('watch');
// Handle a change to a file.
function handleFile(filename) {
var parts = filename.split(path.sep);
parts[0] = '..';
parts[2] = 'lib';
var target = path.resolve(parts.join(path.sep));
fs.copySync(filename, target);
}
// Watch the files in lib.
watch.createMonitor('lib', function (monitor) {
monitor.on('created', function (f) {
watch.createMonitor(f, function (submonitor) {
submonitor.on('changed', handleFile);
});
});
monitor.on('changed', handleFile);
// Handle the initial files.
require('./build');
// eslint-disable-next-line no-console
console.log('Watching the metapackage files...');
});