How to use the os.exit function in os

To help you get started, we’ve selected a few os examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saghul / sjs / test / test-os-fork-exit.js View on Github external
'use strict';

const assert = require('assert');
const os = require('os');


var pid = os.fork();

if (pid == 0) {
    // child
    os.exit(42);
} else {
    // parent
    var r = os.waitpid(pid);
    assert.equal(r.pid, pid);
    assert(os.WIFEXITED(r.status));
    assert.equal(os.WEXITSTATUS(r.status), 42);
}
github kriskowal / narwhal-lib / tests / args / shifting.js View on Github external
exports.testHaltOptions = function () {
    var parser = Parser();
    var options = parser.parse(['command', '--', '-svalue']);
    assert.eq(undefined, options.set);
    assert.eq(['-svalue'], options.args);
};

exports.testNoSuchOption = function () {
    var parser = Parser();
    assert.throwsError(function () {
        parser.parse(['command', '--no-such-option']);
    }, test.Exit)
};

if (require.main == module.id)
    require("os").exit(require("test/runner").run(exports));
github kriskowal / narwhal-lib / tests / commonjs / assert.js View on Github external
assert['throws'](makeBlock(thrower, TypeError));
    //when passing a type, only catch errors of the appropriate type
    var threw = false;
    try {
        assert['throws'](makeBlock(thrower, TypeError), assert.AssertionError);
    } catch (e) {
        threw = true;
        assert.ok(e instanceof TypeError, 'type');
    }
    assert.ok(threw, 'assert.throws with an explicit error is eating extra errors', assert.AssertionError);
    threw = false;

};

if (module === require.main)
    require("os").exit(require("test").run(exports));
github kriskowal / narwhal-lib / tests / uri.js View on Github external
["/foo/bar/baz", "/foo/bar/quux/baz", "quux/baz"],
    ["/foo/bar/baz", "/foo/quux/baz", "../quux/baz"]
], function (from, to, expected) {
    exports[
        'testRelative ' +
        'from: ' + util.repr(from) + ' ' +
        'to: ' + util.repr(to) + ' ' +
        'is: ' + util.repr(expected)
    ] = function () {
        var actual = uri.relative(from, to);
        assert.eq(expected, actual);
    };
});

if (require.main == module.id)
    require("os").exit(require("test/runner").run(exports));
github gmosx / normal-template / tests / all-tests.js View on Github external
exports.testNormalTemplate = require("./normal-template-tests");
exports.testNormalTPP = require("./normal-template/tpp-tests");

if (require.main == module.id)
    require("os").exit(require("test/runner").run(exports));
github kriskowal / narwhal-lib / tests / base64.js View on Github external
var encoded = 'T25jZSB1cG9uIGEgdGltZSwgaW4gYSBmYXIgYXdheSBsYW5kLgo=';

exports.testEncode = function () {
    assert.eq(base64.encode(raw), encoded, 'encoded');
};

exports.testDecode = function () {
    assert.eq(base64.decode(encoded), raw, 'decoded');
};

exports.testEncodeDecode = function () {
    assert.eq(base64.decode(base64.encode(raw)), raw, 'encode decode identity');
};

if (require.main == module.id)
    require("os").exit(require("test/runner").run(exports));
github kriskowal / narwhal-lib / tests / os / popen.js View on Github external
exports.testCommunicateStdout = function () {
    assert.eq("hi\n", os.popen("echo hi").communicate().stdout.read());
    assert.eq("hi\n", os.popen("cat").communicate("hi").stdout.read());
};

exports.testCommunicateStderr = function () {
    assert.eq("hi\n", os.popen("echo hi >&2").communicate().stderr.read());
};

exports.testCommunicateStdin = function () {
    assert.eq("", os.popen("exit 0").communicate("hi").stdin.read());
};

if (require.main == module.id)
    os.exit(require("test/runner").run(exports));
github zenoamaro / emoji-table / src / index.js View on Github external
function handleError(err) {
	console.error(err);
	os.exit(1);
}
github cappuccino / cappuccino / Objective-J / CommonJS / objective-j / lib-js / objective-j / compiler.js View on Github external
if (shouldCheckSyntax)
            {
                try
                {
                    new Function(GET_CODE(fragment));
                }
                catch (e)
                {
                    var lines = code.split("\n"),
                        PAD = 3;
                        
                    print("Syntax error in "+GET_FILE(fragment).path+
                            " on preprocessed line number "+e.lineNumber+"\n"+
                            "\t"+lines.slice(Math.max(0, e.lineNumber - 1 - PAD), e.lineNumber+PAD).join("\n\t"));
                        
                    OS.exit(1);
                }
            }
            
            if (shouldCompress)
            {
                code = compress("function(){" + code + '}', FILE.basename(aFilePath));
            
                code = code.substr("function(){".length, code.length - "function(){};\n\n".length);
            }
            
            preprocessed += MARKER_CODE + ';' + code.length + ';' + code;
        }
    }

    return preprocessed;
}
github 280north / jake / lib / jake.js View on Github external
directories.forEach(function(/*String*/ aDirectory) {
        if (FILE.isDirectory(aDirectory)) {
            if (OS.system("cd " + OS.enquote(aDirectory) + " && " + serializeEnv(env) + " jake " + OS.enquote(aTaskName)))
                OS.exit(1);
        }
    });
}