UNPKG

msbot

Version:

MSBot command line tool for manipulating Microsoft Bot Framework .bot files

42 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Copyright(c) Microsoft Corporation.All rights reserved. * Licensed under the MIT License. */ const child_process = require("child_process"); // child_process.spawn isn't promise and is complicated in how to captures stream of stdout/sterr function spawnAsync(command, stdout, stderr) { return new Promise((resolve, reject) => { const parts = command.split(' '); const p = child_process.spawn(parts[0], parts.slice(1), { shell: true, stdio: ['inherit', 'pipe', 'pipe'] }); let out = ''; let err = ''; p.stderr.on('data', (data) => { let str = data.toString('utf8'); err += str; if (stderr) { stderr(str); } }); p.stdout.on('data', (data) => { let str = data.toString('utf8'); out += str; if (stdout) { stdout(str); } }); p.on('close', (code) => { if (code > 0) { reject(`${command} exit code: ${code}\n${err}`); } else { resolve(out); } }); }); } exports.spawnAsync = spawnAsync; //# sourceMappingURL=processUtils.js.map