-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (29 loc) · 828 Bytes
/
index.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
32
const chokidar = require("chokidar");
const cmd = require('node-cmd');
const path = require('path');
const LIST = require('./watch-list');
const watcher = chokidar.watch(LIST);
const util = require('util');
watcher.on('change',pk => {
console.log('File '+pk+' has been changed');
let _path = path.dirname(pk);
npminstaller(_path);
});
watcher.on('add',pk=>{
console.log('File '+pk+' has been added');
let _path = path.dirname(pk);
npminstaller(_path);
})
var npminstaller = (_path)=>{
var driver = _path.split(":")[0];
cmd.get(util.format(
'cd /d %s && npm install',_path),
function(err, data, stderr){
if (!err) {
console.log('the node-cmd:\n\n',data);
} else {
console.log('error', err);
}
}
);
}