Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including concurrent-run with all npm packages installed. Try it out:

var concurrentRun = require("concurrent-run")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

concurrent-run v2.3.7

Simple, zero dependency, multiple commands runner in concurrent mode.

concurrent-run · npm Build Status

Simple, zero dependency, multiple commands runner in concurrent mode.

Installation

npm

npm install --save-dev concurrent-run

Yarn

yarn add --dev concurrent-run

Usage

CLI

concurrent-run "command1 arg" "command2 arg"

Always surround multiple commands with quotes, otherwise, everything will be treated as a single command.

API

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
    });

Events

  • data gets called once stderr or stdout 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...
});

Contributing

Feel free to open issues or PRs!

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free