Simple, zero dependency, multiple commands runner in concurrent mode.
npm install --save-dev concurrent-run
yarn add --dev concurrent-run
concurrent-run "command1 arg" "command2 arg"
Always surround multiple commands with quotes, otherwise, everything will be treated as a single command.
import { ConcurrentRun, Command } from "concurrent-run";
const concurrent = new ConcurrentRun();
concurrent
.run(["command1 arg", "command2 arg"])
.on("data", (data: Buffer, command: Command) => {
// data from spawned process stderr and stdout
})
.on("close", (exitCode: number, command: Command) => {
// after command is finished
})
.on("error", (err: Error, command: Command) => {
// after an error occurs
});
data
gets called oncestderr
orstdout
of spawned process sends data.
import { ConcurrentRun, Command } from "concurrent-run";
const concurrent = new ConcurrentRun();
concurrent
.run(["command1 arg"])
.on("data", (data: Buffer, command: Command) => {
// do something...
});
close
gets called once command is finished.
import { ConcurrentRun, Command } from "concurrent-run";
const concurrent = new ConcurrentRun();
concurrent
.run(["command1 arg"])
.on("close", (exitCode: number, command: Command) => {
// do something...
});
error
gets called once an error occurs.
import { ConcurrentRun, Command } from "concurrent-run";
const concurrent = new ConcurrentRun();
concurrent
.run(["command1 arg"])
.on("error", (err: Error, command: Command) => {
// do something...
});
Feel free to open issues or PRs!