UNPKG

onemon

Version:

Run a npm script as a deamon, once

42 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); ; /** * @description * Wrapper arround child_process. */ class Runner { constructor(options) { this.stdio = options.stdio || 'inherit'; this.detached = options.detached || false; this.cwd = options.cwd || process.cwd(); this.shell = options.shell || false; } spawn(script) { const PATHES = []; if (process.env.PATH) PATHES.push(process.env.PATH); if (this.cwd) PATHES.push(`${this.cwd}/node_modules/.bin`); return child_process_1.spawn(script, [], { shell: this.shell, detached: this.detached, cwd: this.cwd, stdio: this.stdio, env: Object.assign(Object.assign({}, process.env), { PATH: PATHES.join(':') }) }); } fork(filePath, args, forceColor) { return child_process_1.fork(filePath, args, { env: { FORCE_COLOR: forceColor ? '1' : undefined }, detached: this.detached, stdio: this.stdio, cwd: this.cwd, }); } } exports.default = (options) => new Runner(options); //# sourceMappingURL=runner.js.map