Home Reference Source Repository

Function

Static Public Summary
public

npmRunAll(patternOrPatterns: string | string[], options: object | undefined): Promise

Runs npm-scripts which are matched with given patterns.

Static Private Summary
private

main(args: string[], stdout: stream.Writable, stderr: stream.Writable): Promise

The main process of npm-run-all command.

private

matchTasks(taskList: string[], patterns: string[]): string[]

Enumerates tasks which matches with given patterns.

private

npmRunAll(args: string[], stdout: stream.Writable, stderr: stream.Writable): Promise

Parses arguments, then run specified npm-scripts.

private

printHelp(output: stream.Writable): Promise

Print a help text.

private

printVersion(output: stream.Writable): Promise

Print a version text.

private

Reads package.json in current directry, and gets all npm-scripts names.

private

runTask(task: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise

Run a npm-script of a given name.

private

runTasksInParallel(tasks: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise

Run npm-scripts of given names in parallel.

private

runTasksInSequencial(tasks: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise

Run npm-scripts of given names in sequencial.

private

spawn(command: string, args: string[], options: object): ChildProcess

Launches a new process with the given command.

private

spawn(command: string, args: string[], options: object): ChildProcess

Launches a new process with the given command.

private

Gets a file path of npm command.

Static Public

public npmRunAll(patternOrPatterns: string | string[], options: object | undefined): Promise source

import npmRunAll from 'npm-run-all/lib/npm-run-all.js'

Runs npm-scripts which are matched with given patterns.

Params:

NameTypeAttributeDescription
patternOrPatterns string | string[]

Patterns to run. A pattern is a npm-script name or a Glob-like pattern.

options object | undefined
  • optional

Optional.

options.parallel boolean

If this is true, run scripts in parallel. Otherwise, run scripts in sequencial. Default is false.

options.stdin stream.Readable | null

A readable stream to send messages to stdin of child process. If this is null, ignores it. If this is process.stdin, inherits it. Otherwise, makes a pipe. Default is null.

options.stdout stream.Writable | null

A writable stream to receive messages from stdout of child process. If this is null, cannot send. If this is process.stdout, inherits it. Otherwise, makes a pipe. Default is null.

options.stderr stream.Writable | null

A writable stream to receive messages from stderr of child process. If this is null, cannot send. If this is process.stderr, inherits it. Otherwise, makes a pipe. Default is null.

options.taskList string[]

Actual name list of npm-scripts. This function search npm-script names in this list. If this is null, this function reads package.json of current directly.

options.packageConfig object | null

A map-like object to overwrite package configs. Keys are package names. Every value is a map-like object (Pairs of variable name and value). e.g. {"npm-run-all": {"test": 777}} Default is null.

options.silent boolean

The flag to set silent to the log level of npm. Default is false.

Return:

Promise

A promise object which becomes fullfilled when all npm-scripts are completed.

Static Private

private main(args: string[], stdout: stream.Writable, stderr: stream.Writable): Promise source

The main process of npm-run-all command.

Params:

NameTypeAttributeDescription
args string[]

Arguments to parse.

stdout stream.Writable

A writable stream to print logs.

stderr stream.Writable

A writable stream to print errors.

Return:

Promise

A promise which comes to be fulfilled when all npm-scripts are completed.

private matchTasks(taskList: string[], patterns: string[]): string[] source

import matchTasks from 'npm-run-all/lib/match-tasks.js'

Enumerates tasks which matches with given patterns.

Params:

NameTypeAttributeDescription
taskList string[]

A list of actual task names.

patterns string[]

Pattern texts to match.

Return:

string[]

Tasks which matches with the patterns.

private npmRunAll(args: string[], stdout: stream.Writable, stderr: stream.Writable): Promise source

import npmRunAll from 'npm-run-all/bin/main.js'

Parses arguments, then run specified npm-scripts.

Params:

NameTypeAttributeDescription
args string[]

Arguments to parse.

stdout stream.Writable

A writable stream to print logs.

stderr stream.Writable

A writable stream to print errors.

Return:

Promise

A promise which comes to be fulfilled when all npm-scripts are completed.

private printHelp(output: stream.Writable): Promise source

import printHelp from 'npm-run-all/bin/help.js'

Print a help text.

Params:

NameTypeAttributeDescription
output stream.Writable

A writable stream to print.

Return:

Promise

Always a fulfilled promise.

private printVersion(output: stream.Writable): Promise source

import printVersion from 'npm-run-all/bin/version.js'

Print a version text.

Params:

NameTypeAttributeDescription
output stream.Writable

A writable stream to print.

Return:

Promise

Always a fulfilled promise.

private readTasks(): string[] source

import readTasks from 'npm-run-all/lib/read-tasks.js'

Reads package.json in current directry, and gets all npm-scripts names. If package.json has not found, throws an error.

Return:

string[]

npm-scripts names.

private runTask(task: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise source

import runTask from 'npm-run-all/lib/run-task.js'

Run a npm-script of a given name. The return value is a promise which has an extra method: abort(). The abort() kills the child process to run the npm-script.

Params:

NameTypeAttributeDescription
task string

A npm-script name to run.

stdin stream.Readable | null

A readable stream to send messages to stdin of child process. If this is null, ignores it. If this is process.stdin, inherits it. Otherwise, makes a pipe.

stdout stream.Writable | null

A writable stream to receive messages from stdout of child process. If this is null, cannot send. If this is process.stdout, inherits it. Otherwise, makes a pipe.

stderr stream.Writable | null

A writable stream to receive messages from stderr of child process. If this is null, cannot send. If this is process.stderr, inherits it. Otherwise, makes a pipe.

prefixOptions string[]

An array of options which are inserted before the task name.

Return:

Promise

A promise object which becomes fullfilled when the npm-script is completed. This promise object has an extra method: abort().

private runTasksInParallel(tasks: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise source

import runTasksInParallel from 'npm-run-all/lib/run-tasks-in-parallel.js'

Run npm-scripts of given names in parallel.

If a npm-script exited with a non-zero code, this aborts other all npm-scripts.

Params:

NameTypeAttributeDescription
tasks string

A list of npm-script name to run in parallel.

stdin stream.Readable | null

A readable stream to send messages to stdin of child process. If this is null, ignores it. If this is process.stdin, inherits it. Otherwise, makes a pipe.

stdout stream.Writable | null

A writable stream to receive messages from stdout of child process. If this is null, cannot send. If this is process.stdout, inherits it. Otherwise, makes a pipe.

stderr stream.Writable | null

A writable stream to receive messages from stderr of child process. If this is null, cannot send. If this is process.stderr, inherits it. Otherwise, makes a pipe.

prefixOptions string[]

An array of options which are inserted before the task name.

Return:

Promise

A promise object which becomes fullfilled when all npm-scripts are completed.

private runTasksInSequencial(tasks: string, stdin: stream.Readable | null, stdout: stream.Writable | null, stderr: stream.Writable | null, prefixOptions: string[]): Promise source

import runTasksInSequencial from 'npm-run-all/lib/run-tasks-in-sequencial.js'

Run npm-scripts of given names in sequencial.

If a npm-script exited with a non-zero code, this aborts subsequent npm-scripts.

Params:

NameTypeAttributeDescription
tasks string

A list of npm-script name to run in sequencial.

stdin stream.Readable | null

A readable stream to send messages to stdin of child process. If this is null, ignores it. If this is process.stdin, inherits it. Otherwise, makes a pipe.

stdout stream.Writable | null

A writable stream to receive messages from stdout of child process. If this is null, cannot send. If this is process.stdout, inherits it. Otherwise, makes a pipe.

stderr stream.Writable | null

A writable stream to receive messages from stderr of child process. If this is null, cannot send. If this is process.stderr, inherits it. Otherwise, makes a pipe.

prefixOptions string[]

An array of options which are inserted before the task name.

Return:

Promise

A promise object which becomes fullfilled when all npm-scripts are completed.

private spawn(command: string, args: string[], options: object): ChildProcess source

import spawn from 'npm-run-all/lib/spawn-posix.js'

Launches a new process with the given command. This is almost same as child_process.spawn.

This returns a ChildProcess instance. kill method of the instance kills the new process and its sub processes.

Params:

NameTypeAttributeDescription
command string

The command to run.

args string[]

List of string arguments.

options object

Options.

Return:

ChildProcess

A ChildProcess instance of new process.

private spawn(command: string, args: string[], options: object): ChildProcess source

import spawn from 'npm-run-all/lib/spawn-win32.js'

Launches a new process with the given command. This is almost same as child_process.spawn.

This returns a ChildProcess instance. kill method of the instance kills the new process and its sub processes forcibly.

Params:

NameTypeAttributeDescription
command string

The command to run.

args string[]

List of string arguments.

options object

Options.

Return:

ChildProcess

A ChildProcess instance of new process.

private whichNpm(): Promise<string> source

import whichNpm from 'npm-run-all/lib/which-npm.js'

Gets a file path of npm command.

Return:

Promise<string>

A promise object which becomes fullfilled when it got a file path of npm command.