UNPKG

await-exec-typescript

Version:

Small promise wrapper around node's `child_process#exec` allowing you to use async/await syntax for commands you want to execute.

20 lines (19 loc) 644 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cp = require("child_process"); function Exec(command, options = { log: false, cwd: process.cwd() }) { if (options.log) console.log(command); return new Promise((done, failed) => { cp.exec(command, Object.assign({}, options), (err, stdout, stderr) => { if (err) { process.stdout.write(stdout); process.stderr.write(stderr); failed(err); return; } done({ stdout, stderr }); }); }); } exports.default = Exec;