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