License Source —» Website npm
FPL github.com/cadorn/runbash CircleCI cadorn.github.io/runbash runbash

runbash

Run bash and bash.origin from NodeJS. Easily. Promise.

Usage

const RUNBASH = require("runbash");

Run Process .then resolve

RUNBASH([
    "echo 'Hello World'",       // Run a command
    "echo 'FOO: BAR'"           // Export a variable
], {                            // Defaults
    verbose: false,             // Log internal activity
    progress: false,            // Log process output
    wrappers: {                 // Setup environment before commands
        "bash.origin": true     // Load bash.origin
    },
    wait: true,                 // Resolve when process ends
    exports: false,             // Scan for /^<NAME>: <VALUE>$/
}).then(function (result) {

    // result.code ~ 0          // Process exit code
    // result.stdout ~ []
    // result.stderr ~ []
    // result.exports[<NAME>] ~ <VALUE>

    return null;
}).catch(console.error);

Start Process .then resolve

RUNBASH([], {
    wait: false
}).then(function (result) {

    // result.process ~ <Process Object>
    // result.killDeep()        // Kill process and spawned child processes

    return null;
}).catch(console.error);

Provenance

Original Source Logic under Free Public License by Christoph Dorn since 2015.