concurrently

  • Version 9.0.1
  • Published
  • 401 kB
  • 7 dependencies
  • MIT license

Install

npm i concurrently
yarn add concurrently
pnpm add concurrently

Overview

Run commands concurrently

Index

Functions

function concurrently

concurrently: typeof concurrently;

    function createConcurrently

    createConcurrently: (
    baseCommands: ConcurrentlyCommandInput[],
    baseOptions?: Partial<ConcurrentlyOptions>
    ) => ConcurrentlyResult;
    • Core concurrently functionality -- spawns the given commands concurrently and returns the commands themselves + the result according to the specified success condition.

      See Also

      • CompletionListener

    Classes

    class Command

    class Command implements CommandInfo {}

      constructor

      constructor(
      {
      index,
      name,
      command,
      prefixColor,
      env,
      cwd,
      ipc,
      }: CommandInfo & { index: number },
      spawnOpts: SpawnOptions,
      spawn: SpawnCommand,
      killProcess: KillProcess
      );

        property close

        readonly close: Rx.Subject<CloseEvent>;

          property command

          readonly command: string;

          property cwd

          readonly cwd?: string;

          property env

          readonly env: Record<string, unknown>;

          property error

          readonly error: Rx.Subject<unknown>;

            property exited

            exited: boolean;

              property index

              readonly index: number;

                property ipc

                readonly ipc?: number;

                property killed

                killed: boolean;

                  property messages

                  readonly messages: {
                  incoming: Rx.Subject<MessageEvent>;
                  outgoing: Rx.ReplaySubject<OutgoingMessageEvent>;
                  };

                    property name

                    readonly name: string;

                    property pid

                    pid?: number;

                      property prefixColor

                      readonly prefixColor?: string;

                      property process

                      process?: any;

                        property state

                        state: CommandState;

                          property stderr

                          readonly stderr: Rx.Subject<Buffer>;

                            property stdin

                            stdin?: Writable;

                              property stdout

                              readonly stdout: Rx.Subject<Buffer>;

                                property timer

                                readonly timer: Rx.Subject<TimerEvent>;

                                  method canKill

                                  static canKill: (
                                  command: Command
                                  ) => command is Command & { pid: number; process: ChildProcess };
                                  • Detects whether a command can be killed.

                                    Also works as a type guard on the input command.

                                  method kill

                                  kill: (code?: string) => void;
                                  • Kills this command, optionally specifying a signal to send to it.

                                  method send

                                  send: (
                                  message: object,
                                  handle?: SendHandle,
                                  options?: MessageOptions
                                  ) => Promise<void>;
                                  • Sends a message to the underlying process once it starts.

                                    Returns

                                    Promise that resolves when the message is sent, or rejects if it fails to deliver the message.

                                    Throws

                                    If the command doesn't have an IPC channel enabled

                                  method start

                                  start: () => void;
                                  • Starts this command, piping output, error and close events onto the corresponding observables.

                                  class InputHandler

                                  class InputHandler implements FlowController {}
                                  • Sends input from concurrently through to commands.

                                    Input can start with a command identifier, in which case it will be sent to that specific command. For instance, 0:bla will send bla to command at index 0, and server:stop will send stop to command with name server.

                                    If the input doesn't start with a command identifier, it is then always sent to the default target.

                                  constructor

                                  constructor({
                                  defaultInputTarget,
                                  inputStream,
                                  pauseInputStreamOnFinish,
                                  logger,
                                  }: {
                                  inputStream?: Readable;
                                  logger: Logger;
                                  defaultInputTarget?: CommandIdentifier;
                                  pauseInputStreamOnFinish?: boolean;
                                  });

                                    method handle

                                    handle: (commands: Command[]) => {
                                    commands: Command[];
                                    onFinish?: () => void | undefined;
                                    };

                                      class KillOnSignal

                                      class KillOnSignal implements FlowController {}
                                      • Watches the main concurrently process for signals and sends the same signal down to each spawned command.

                                      constructor

                                      constructor({
                                      process,
                                      abortController,
                                      }: {
                                      process: EventEmitter;
                                      abortController?: AbortController;
                                      });

                                        method handle

                                        handle: (commands: Command[]) => { commands: Command[] };

                                          class KillOthers

                                          class KillOthers implements FlowController {}
                                          • Sends a SIGTERM signal to all commands when one of the commands exits with a matching condition.

                                          constructor

                                          constructor({
                                          logger,
                                          abortController,
                                          conditions,
                                          killSignal,
                                          }: {
                                          logger: Logger;
                                          abortController?: AbortController;
                                          conditions: ProcessCloseCondition | ProcessCloseCondition[];
                                          killSignal: string | undefined;
                                          });

                                            method handle

                                            handle: (commands: Command[]) => { commands: Command[] };

                                              class LogError

                                              class LogError implements FlowController {}
                                              • Logs when commands failed executing, e.g. due to the executable not existing in the system.

                                              constructor

                                              constructor({ logger }: { logger: Logger });

                                                method handle

                                                handle: (commands: Command[]) => { commands: Command[] };

                                                  class LogExit

                                                  class LogExit implements FlowController {}
                                                  • Logs the exit code/signal of commands.

                                                  constructor

                                                  constructor({ logger }: { logger: Logger });

                                                    method handle

                                                    handle: (commands: Command[]) => { commands: Command[] };

                                                      class Logger

                                                      class Logger {}

                                                        constructor

                                                        constructor({
                                                        hide,
                                                        prefixFormat,
                                                        commandLength,
                                                        raw,
                                                        timestampFormat,
                                                        }: {
                                                        hide?: CommandIdentifier[];
                                                        raw?: boolean;
                                                        prefixFormat?: string;
                                                        commandLength?: number;
                                                        timestampFormat?: string;
                                                        });

                                                          property output

                                                          readonly output: Rx.Subject<{ command: Command | undefined; text: string }>;
                                                          • Observable that emits when there's been output logged. If command is is undefined, then the log is for a global event.

                                                          method colorText

                                                          colorText: (command: Command, text: string) => string;

                                                            method emit

                                                            emit: (command: Command | undefined, text: string) => void;

                                                              method getPrefix

                                                              getPrefix: (command: Command) => string;

                                                                method getPrefixContent

                                                                getPrefixContent: (
                                                                command: Command
                                                                ) => { type: 'default' | 'template'; value: string } | undefined;

                                                                  method log

                                                                  log: (prefix: string, text: string, command?: Command) => void;

                                                                    method logCommandEvent

                                                                    logCommandEvent: (text: string, command: Command) => void;
                                                                    • Logs an event for a command (e.g. start, stop).

                                                                      If raw mode is on, then nothing is logged.

                                                                    method logCommandText

                                                                    logCommandText: (text: string, command: Command) => void;

                                                                      method logGlobalEvent

                                                                      logGlobalEvent: (text: string) => void;
                                                                      • Logs a global event (e.g. sending signals to processes).

                                                                        If raw mode is on, then nothing is logged.

                                                                      method logTable

                                                                      logTable: (tableContents: Record<string, unknown>[]) => void;
                                                                      • Logs a table from an input object array, like console.table.

                                                                        Each row is a single input item, and they are presented in the input order.

                                                                      method setPrefixLength

                                                                      setPrefixLength: (length: number) => void;

                                                                        method toggleColors

                                                                        toggleColors: (on: boolean) => void;
                                                                        • Toggles colors on/off globally.

                                                                        class LogOutput

                                                                        class LogOutput implements FlowController {}
                                                                        • Logs the stdout and stderr output of commands.

                                                                        constructor

                                                                        constructor({ logger }: { logger: Logger });

                                                                          method handle

                                                                          handle: (commands: Command[]) => { commands: Command[] };

                                                                            class LogTimings

                                                                            class LogTimings implements FlowController {}
                                                                            • Logs timing information about commands as they start/stop and then a summary when all commands finish.

                                                                            constructor

                                                                            constructor({
                                                                            logger,
                                                                            timestampFormat,
                                                                            }: {
                                                                            logger?: Logger;
                                                                            timestampFormat?: string;
                                                                            });

                                                                              method handle

                                                                              handle: (
                                                                              commands: Command[]
                                                                              ) =>
                                                                              | { commands: Command[]; onFinish?: undefined }
                                                                              | { commands: Command[]; onFinish: () => void };

                                                                                method mapCloseEventToTimingInfo

                                                                                static mapCloseEventToTimingInfo: ({
                                                                                command,
                                                                                timings,
                                                                                killed,
                                                                                exitCode,
                                                                                }: CloseEvent) => TimingInfo;

                                                                                  class RestartProcess

                                                                                  class RestartProcess implements FlowController {}
                                                                                  • Restarts commands that fail up to a defined number of times.

                                                                                  constructor

                                                                                  constructor({
                                                                                  delay,
                                                                                  tries,
                                                                                  logger,
                                                                                  scheduler,
                                                                                  }: {
                                                                                  delay?: RestartDelay;
                                                                                  tries?: number;
                                                                                  logger: Logger;
                                                                                  scheduler?: Rx.SchedulerLike;
                                                                                  });

                                                                                    property tries

                                                                                    readonly tries: number;

                                                                                      method handle

                                                                                      handle: (commands: Command[]) => { commands: Command[] };

                                                                                        Interfaces

                                                                                        interface CloseEvent

                                                                                        interface CloseEvent {}

                                                                                          property command

                                                                                          command: CommandInfo;

                                                                                            property exitCode

                                                                                            exitCode: string | number;
                                                                                            • The exit code or signal for the command.

                                                                                            property index

                                                                                            index: number;
                                                                                            • The command's index among all commands ran.

                                                                                            property killed

                                                                                            killed: boolean;
                                                                                            • Whether the command exited because it was killed.

                                                                                            property timings

                                                                                            timings: {
                                                                                            startDate: Date;
                                                                                            endDate: Date;
                                                                                            durationSeconds: number;
                                                                                            };

                                                                                              interface FlowController

                                                                                              interface FlowController {}
                                                                                              • Interface for a class that controls and/or watches the behavior of commands.

                                                                                                This may include logging their output, creating interactions between them, or changing when they actually finish.

                                                                                              method handle

                                                                                              handle: (commands: Command[]) => {
                                                                                              commands: Command[];
                                                                                              onFinish?: () => void | Promise<void>;
                                                                                              };

                                                                                                interface TimerEvent

                                                                                                interface TimerEvent {}

                                                                                                  property endDate

                                                                                                  endDate?: Date;

                                                                                                    property startDate

                                                                                                    startDate: Date;

                                                                                                      Type Aliases

                                                                                                      type CommandIdentifier

                                                                                                      type CommandIdentifier = string | number;
                                                                                                      • Identifier for a command; if string, it's the command's name, if number, it's the index.

                                                                                                      type ConcurrentlyCommandInput

                                                                                                      type ConcurrentlyCommandInput =
                                                                                                      | string
                                                                                                      | ({
                                                                                                      command: string;
                                                                                                      } & Partial<CommandInfo>);
                                                                                                      • A command that is to be passed into concurrently(). If value is a string, then that's the command's command line. Fine grained options can be defined by using the object format.

                                                                                                      type ConcurrentlyOptions

                                                                                                      type ConcurrentlyOptions = Omit<BaseConcurrentlyOptions, 'abortSignal' | 'hide'> & {
                                                                                                      /**
                                                                                                      * Which command(s) should have their output hidden.
                                                                                                      */
                                                                                                      hide?: CommandIdentifier | CommandIdentifier[];
                                                                                                      /**
                                                                                                      * The prefix format to use when logging a command's output.
                                                                                                      * Defaults to the command's index.
                                                                                                      */
                                                                                                      prefix?: string;
                                                                                                      /**
                                                                                                      * How many characters should a prefix have at most, used when the prefix format is `command`.
                                                                                                      */
                                                                                                      prefixLength?: number;
                                                                                                      /**
                                                                                                      * Pads short prefixes with spaces so that all prefixes have the same length.
                                                                                                      */
                                                                                                      padPrefix?: boolean;
                                                                                                      /**
                                                                                                      * Whether output should be formatted to include prefixes and whether "event" logs will be logged.
                                                                                                      */
                                                                                                      raw?: boolean;
                                                                                                      /**
                                                                                                      * Date format used when logging date/time.
                                                                                                      * @see https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
                                                                                                      */
                                                                                                      timestampFormat?: string;
                                                                                                      defaultInputTarget?: CommandIdentifier;
                                                                                                      inputStream?: Readable;
                                                                                                      handleInput?: boolean;
                                                                                                      pauseInputStreamOnFinish?: boolean;
                                                                                                      /**
                                                                                                      * How much time in milliseconds to wait before restarting a command.
                                                                                                      *
                                                                                                      * @see RestartProcess
                                                                                                      */
                                                                                                      restartDelay?: RestartDelay;
                                                                                                      /**
                                                                                                      * How many times commands should be restarted when they exit with a failure.
                                                                                                      *
                                                                                                      * @see RestartProcess
                                                                                                      */
                                                                                                      restartTries?: number;
                                                                                                      /**
                                                                                                      * Under which condition(s) should other commands be killed when the first one exits.
                                                                                                      *
                                                                                                      * @see KillOthers
                                                                                                      */
                                                                                                      killOthers?: ProcessCloseCondition | ProcessCloseCondition[];
                                                                                                      /**
                                                                                                      * Whether to output timing information for processes.
                                                                                                      *
                                                                                                      * @see LogTimings
                                                                                                      */
                                                                                                      timings?: boolean;
                                                                                                      /**
                                                                                                      * Clean up command(s) to execute before exiting concurrently.
                                                                                                      * These won't be prefixed and don't affect concurrently's exit code.
                                                                                                      */
                                                                                                      teardown?: readonly string[];
                                                                                                      /**
                                                                                                      * List of additional arguments passed that will get replaced in each command.
                                                                                                      * If not defined, no argument replacing will happen.
                                                                                                      */
                                                                                                      additionalArguments?: string[];
                                                                                                      };

                                                                                                        type ConcurrentlyResult

                                                                                                        type ConcurrentlyResult = {
                                                                                                        /**
                                                                                                        * All commands created and ran by concurrently.
                                                                                                        */
                                                                                                        commands: Command[];
                                                                                                        /**
                                                                                                        * A promise that resolves when concurrently ran successfully according to the specified
                                                                                                        * success condition, or reject otherwise.
                                                                                                        *
                                                                                                        * Both the resolved and rejected value is a list of all the close events for commands that
                                                                                                        * spawned; commands that didn't spawn are filtered out.
                                                                                                        */
                                                                                                        result: Promise<CloseEvent[]>;
                                                                                                        };

                                                                                                          Package Files (14)

                                                                                                          Dependencies (7)

                                                                                                          Dev Dependencies (29)

                                                                                                          Peer Dependencies (0)

                                                                                                          No peer dependencies.

                                                                                                          Badge

                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/concurrently.

                                                                                                          • Markdown
                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/concurrently)
                                                                                                          • HTML
                                                                                                            <a href="https://www.jsdocs.io/package/concurrently"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>