Last change
on this file since 274 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.1 KB
|
Line | |
---|
1 | define(["../fileHandleThrottle", "../messages"], function(fht, messages) { |
---|
2 | var spawn= require.nodeRequire("child_process").spawn; |
---|
3 | return { |
---|
4 | cwd:process.cwd, |
---|
5 | exit:function(code){ |
---|
6 | // no more messages |
---|
7 | messages.stop(); |
---|
8 | |
---|
9 | // allow whatever is in the stdout buffer to be pumped |
---|
10 | process.stdout.on('close', function(){ |
---|
11 | process.exit(code); |
---|
12 | }); |
---|
13 | process.stdout.end(); |
---|
14 | }, |
---|
15 | |
---|
16 | exec:function() { |
---|
17 | // signature is (command, arg1, ..., argn, errorMessage, bc, callback) |
---|
18 | for(var command= arguments[0], args= [], i= 1; i<arguments.length-3; i++){ |
---|
19 | args.push(arguments[i]); |
---|
20 | } |
---|
21 | var |
---|
22 | errorMessage= arguments[i++], |
---|
23 | bc= arguments[i++], |
---|
24 | callback= arguments[i]; |
---|
25 | fht.enqueue(function(){ |
---|
26 | var |
---|
27 | text= "", |
---|
28 | process= spawn(command, args); |
---|
29 | process.on("exit", function(code){ |
---|
30 | fht.release(); |
---|
31 | if(code){ |
---|
32 | bc.log("execFailed", ["message", errorMessage, "output", text]); |
---|
33 | } |
---|
34 | callback && callback(code, text); |
---|
35 | }); |
---|
36 | process.stdout.on("data", function(data){ |
---|
37 | text+= data; |
---|
38 | }); |
---|
39 | process.stderr.on("data", function(data){ |
---|
40 | text+= data; |
---|
41 | }); |
---|
42 | }); |
---|
43 | } |
---|
44 | }; |
---|
45 | }); |
---|
46 | |
---|
Note: See
TracBrowser
for help on using the repository browser.