aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/ChildProcess.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/PursLoader/ChildProcess.js')
-rw-r--r--src/PursLoader/ChildProcess.js40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/PursLoader/ChildProcess.js b/src/PursLoader/ChildProcess.js
deleted file mode 100644
index d62aef6..0000000
--- a/src/PursLoader/ChildProcess.js
+++ /dev/null
@@ -1,40 +0,0 @@
1'use strict';
2
3// module PursLoader.ChildProcess
4
5var child_process = require('child_process');
6
7var chalk = require('chalk');
8
9function spawnFn(command, args, errback, callback) {
10 return function(){
11 var process = child_process.spawn(command, args);
12
13 var stdout = new Buffer(0);
14
15 var stderr = new Buffer(0);
16
17 process.stdout.on('data', function(data){
18 stdout = Buffer.concat([stdout, new Buffer(data)]);
19 });
20
21 process.stderr.on('data', function(data){
22 stderr = Buffer.concat([stderr, new Buffer(data)]);
23 });
24
25 process.on('close', function(code){
26 var output = stdout.toString('utf-8');
27
28 var error = stderr.toString('utf-8');
29
30 if (error.length > 0) {
31 console.error('\n' + chalk.red('*') + ' ' + error);
32 }
33
34 if (code !== 0) errback(new Error('Process terminated with code ' + code))();
35 else callback(output)();
36 });
37 };
38}
39
40exports.spawnFn = spawnFn;