forked from guileen/knockout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
automake.js
44 lines (36 loc) · 1.22 KB
/
automake.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
33
34
35
36
37
38
39
40
41
42
43
44
var watch = require('watch')
, spawn = require('child_process').spawn
, exec = require('child_process').exec
, myconsole = require('myconsole')
;
myconsole.replace();
watch.createMonitor('.', { ignoreDotFiles: true }, function (monitor) {
monitor.on("created", check_make)
monitor.on("changed", check_make)
monitor.on("removed", check_make)
});
function check_make(f) {
var match = f == 'Makefile' || /\.jade$/.test(f) || /public\/marklet\/.*\.js/.test(f);
match = match && ! /.*\/(marklet|.*template)(.min)?.js$/.test(f)
match = match && ! /(^\.|.*\/\.).*/.test(f)
if( ! match ) return;
console.log(f + ' changed, start make')
exec('make', function(error, stdout, stderr) {
if(error) myconsole.traceError(error);
if(stdout) console.log(stdout);
if(stderr) console.error(stderr);
})
// var makeprg = spawn('make')
// makeprg.stdout.on('data', function(data) {
// console.log(data.toString());
// });
// makeprg.stderr.on('data', function(data) {
// console.log(data.toString());
// });
// makeprg.on('exit', function(code) {
// console.log('make done ' + code);
// })
// makeprg.on('error', function(error) {
// console.traceError(error);
// })
}