Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/lib/os.js
blob: 7bffef7eb8cb9c34dc09acc5b32c6e614e39d8fd (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

var platform = require('os-platform');
for (var name in platform) {
    if (Object.prototype.hasOwnProperty.call(platform, name)) {
        exports[name] = platform[name];
    }
}

exports.system = function (command, options) {
    var process = exports.popen(command, options);
    return process.communicate(
        '',
        system.stdout,
        system.stderr
    ).code;
};

exports.command = function (command) {
    var process = exports.popen(command);
    var result = process.communicate();
    if (result.code !== 0)
        throw new Error(result.stderr.read());
    return result.stdout.read();
};

exports.enquote = function (word) {
    return "'" + String(word).replace(/'/g, "'\"'\"'") + "'";
};