-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (33 loc) · 1.08 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var spawn = require('child_process').spawn;
// FIXME: Don't know why this don't work
// var process.stdin.resume();
// process.on('SIGINT', function() {
// console.log('Closed ' + process.pid);
// process.exit();
// });
var stdin = process.stdin;
// console.log(stdin);
// console.log(stdin.constructor.name);
// without this, we would only get streams once enter is pressed
stdin.setRawMode( true );
// resume stdin in the parent process (node app won't quit all by itself
// unless an error or process.exit() happens)
stdin.resume();
// i don't want binary, do you?
stdin.setEncoding( 'utf8' );
function exit( key ){
// ctrl-c ( end of text )
if ( key === '\u0003' ) {
process.stdout.write( "exit process " + process.pid + "\n" );
process.exit();
}
}
// on any data into stdin
stdin.on('data', exit);
function spawnChildren(e) {
process.stdin.removeAllListeners('data');
process.stdin.pause();
p = spawn('gulp', process.argv.slice(2), {stdio: [process.stdin, process.stdout, process.stderr], detached: true});
process.exit();
}
module.exports = spawnChildren;