forked from jupyter/notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathless-watch
More file actions
executable file
·42 lines (33 loc) · 1.15 KB
/
Copy pathless-watch
File metadata and controls
executable file
·42 lines (33 loc) · 1.15 KB
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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
/**
Usage:
./scripts/less-watch [watchPath]
Example:
./scripts/less-watch ./notebook/static/notebook/less
**/
var less = require('less');
var fs = require('fs');
var path = require('path');
var child_process = require('child_process');
function printResults(err, stdout, stderr) {
if (err) return console.log(err);
if (stdout) console.log(stdout);
if (stderr) console.log(stderr);
}
function compileLESS() {
child_process.exec('lessc --include-path=notebook/static --verbose notebook/static/style/style.less notebook/static/style/style.min.css', printResults);
child_process.exec('lessc --include-path=notebook/static --verbose notebook/static/style/ipython.less notebook/static/style/ipython.min.css', printResults);
}
function watchDir(dir) {
var rootPath = path.join(__dirname, '..');
var watchPath = path.resolve(dir);
console.log('less-watch:', 'watching:', path.relative(rootPath, watchPath));
fs.watch(watchPath, {recursive: true}, function(event, file) {
if (file && /.+\.less$/.test(file)) {
console.log('less-watch:', 'modified:', file);
compileLESS();
}
});
}
compileLESS();
watchDir(process.argv[2]);