UNPKG

@digipolis/start-ui

Version:
19 lines (15 loc) 608 B
import { spawn } from 'child_process'; export function execPromise(command, options = [], spawnOptions = {}) { return new Promise(((resolve, reject) => { let child; if (!/^win/.test(process.platform)) { // linux child = spawn(command, options, { stdio: 'inherit', ...spawnOptions }); } else { // windows child = spawn('cmd', ['/s', '/c', command].concat(options), { stdio: 'inherit', ...spawnOptions }); } child.on('data', (data) => console.log(data)); child.on('close', resolve); child.on('error', (error) => reject(error)); })); } export default execPromise;