Home Reference Source Repository

Function

Static Public Summary
public

Generates a command that uses concurrently to run scripts concurrently.

public

copy(args: string): string

Gets a script that uses the cpy-cli binary.

public

Gets a script that uses the cross-env binary.

public

ifNotWindows(script: string, altScript: string): string

Simply calls ifWindows(altScript, script)

public

ifWindows(script: string, altScript: string): string

Takes two scripts and returns the first if the current environment is windows, and the second if the current environment is not windows

public

mkdirp(args: string): string

Gets a script that uses the mkdirp binary.

public

open(args: string): string

Gets a script that uses the opn-cli binary.

public

rimraf(args: string): string

Gets a script that uses the rimraf binary.

public

EXPERIMENTAL: THIS DOES NOT CURRENTLY WORK FOR ALL TERMINALS Takes a command and returns a version that should run in another tab/window of your terminal.

public

series(scripts: ...string): string

Accepts any number of scripts, filters out any falsy ones and joins them with ' && '

Static Public

public concurrent(scripts: ConcurrentScripts): string source

import {concurrent} from 'nps-utils/src/index.js'

Generates a command that uses concurrently to run scripts concurrently. Adds a few flags to make it behave as you probably want (like --kill-others-on-fail). In addition, it adds color and labels where the color can be specified or is defaulted and the label is based on the key for the script.

Params:

NameTypeAttributeDescription
scripts ConcurrentScripts

the scripts to run note: this function filters out falsy values :)

Return:

string

the command to run

Example:

// returns a bit of a long script that can vary slightly
// based on your environment... :)
concurrent({
  lint: {
    script: 'eslint .',
    color: 'bgGreen.white.dim',
  },
  test: 'jest',
  build: {
    script: 'webpack'
  }
})

public copy(args: string): string source

import {copy} from 'nps-utils/src/index.js'

Gets a script that uses the cpy-cli binary. cpy-cli is a dependency of nps-utils, so you don't need to install it yourself.

Params:

NameTypeAttributeDescription
args string

args to pass to cpy-cli learn more from http://npm.im/cpy-cli

Return:

string

the command with the cpy-cli binary

public crossEnv(args: string): string source

import {crossEnv} from 'nps-utils/src/index.js'

Gets a script that uses the cross-env binary. cross-env is a dependency of nps-utils, so you don't need to install it yourself.

Params:

NameTypeAttributeDescription
args string

args to pass to cross-env learn more from http://npm.im/cross-env

Return:

string

the command with the cross-env binary

public ifNotWindows(script: string, altScript: string): string source

import {ifNotWindows} from 'nps-utils/src/index.js'

Simply calls ifWindows(altScript, script)

Params:

NameTypeAttributeDescription
script string

the script to use for non-windows

altScript string

the script to use for windows

Return:

string

the command to run

public ifWindows(script: string, altScript: string): string source

import {ifWindows} from 'nps-utils/src/index.js'

Takes two scripts and returns the first if the current environment is windows, and the second if the current environment is not windows

Params:

NameTypeAttributeDescription
script string

the script to use for windows

altScript string

the script to use for non-windows

Return:

string

the command to run

public mkdirp(args: string): string source

import {mkdirp} from 'nps-utils/src/index.js'

Gets a script that uses the mkdirp binary. mkdirp is a dependency of nps-utils, so you don't need to install it yourself.

Params:

NameTypeAttributeDescription
args string

args to pass to mkdirp learn more from http://npm.im/mkdirp

Return:

string

the command with the mkdirp binary

public open(args: string): string source

import {open} from 'nps-utils/src/index.js'

Gets a script that uses the opn-cli binary. opn-cli is a dependency of nps-utils, so you don't need to install it yourself.

Params:

NameTypeAttributeDescription
args string

args to pass to opn-cli learn more from http://npm.im/opn-cli

Return:

string

the command with the opn-cli binary

public rimraf(args: string): string source

import {rimraf} from 'nps-utils/src/index.js'

Gets a script that uses the rimraf binary. rimraf is a dependency of nps-utils, so you don't need to install it yourself.

Params:

NameTypeAttributeDescription
args string

args to pass to rimraf learn more from http://npm.im/rimraf

Return:

string

the command with the rimraf binary

public runInNewWindow(command: string): string source

import {runInNewWindow} from 'nps-utils/src/index.js'

EXPERIMENTAL: THIS DOES NOT CURRENTLY WORK FOR ALL TERMINALS Takes a command and returns a version that should run in another tab/window of your terminal. Currently only supports Windows cmd (new window) and Terminal.app (new tab)

Params:

NameTypeAttributeDescription
command string

the command to run in a new tab/window

Return:

string

the command to run

Example:

// returns some voodoo magic to make the terminal do what you want
runInNewWindow('echo hello')

public series(scripts: ...string): string source

import {series} from 'nps-utils/src/index.js'

Accepts any number of scripts, filters out any falsy ones and joins them with ' && '

Params:

NameTypeAttributeDescription
scripts ...string

Any number of strings representing commands

Return:

string

the command that will execute the given scripts in series

Example:

// returns 'eslint && jest && webpack --env.production'
series('eslint', 'jest', 'webpack --env.production')