summaryrefslogtreecommitdiff
path: root/scripts/lib/system.js
blob: c9b870283996176a202d947101677f08ded4f4fb (plain)
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
(function() {
    Object.defineProperties(system, {
        "spawn" : 
        {
            value : (function() {
                return function(command, onStdout, onStderr, stdin, environ, toStdin) {
                    var stdout, stderr;
                    return system._spawn(command, 
                                function(response) {
                                    var ret;
                                    stdout = response;
                                    if (onStdout)
                                        ret = onStdout.call(onStdout, response);
                                    return ret;
                                }, 
                                function(response) {
                                    var ret;
                                    stderr = response;
                                    if (onStderr)
                                        ret = onStderr.call(onStderr, response);
                                    return ret;
                                }, 
                                stdin, environ, toStdin).then(
                                    function() { return stdout; }, 
                                    function() { return stdin; }
                                );
                };
            })()
        }
    });
    Object.freeze(system);
})();