-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestWatch.js
More file actions
executable file
·53 lines (47 loc) · 1.43 KB
/
Copy pathtestWatch.js
File metadata and controls
executable file
·53 lines (47 loc) · 1.43 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
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
var mpath = process.argv.slice(2);
if(mpath && mpath.length >0 ) {
var watch = require('./watch' ).create(function(watch){
/*watch.exclude(['*index.js']);
watch.exclude(/.*index.js$/);
watch.exclude(new RegExp(/.*index.js$/));*/
/*watch.listeners({
'create': function(path, stat){
console.log('create:' + path, stat);
},
'delete': function(path, stat){
console.log('delete:' + path, stat);
},
'change': function(path, stat){
console.log('change:' + path, stat);
}
}).watchTree(__dirname + '/test', function(err, fileCount, dirCount){
console.log('test: ', arguments);
});*/
watch.listeners({
'createfile': function(path, stat){
console.log('createfile:' + path, stat);
},
'deletefile': function(path, stat){
console.log('deletefile:' + path, stat);
},
'changefile': function(path, stat){
console.log('changefile:' + path, stat);
},
'createdirectory': function(path, stat){
console.log('createdirectory:' + path, stat);
},
'deletedirectory': function(path, stat){
console.log('deletedirectory:' + path, stat);
},
'changedirectory': function(path, stat){
console.log('changedirectory:' + path, stat);
}
} ).watchTree(mpath[0], function(err, fileCount, dirCount){
console.log('当前监视文件: ', arguments);
console.log(Object.keys(watch.files));
});
});
} else {
console.log('Usage: ./testWatch.js dirname');
}