@bconnorwhite/run-env

1.1.6 • Public • Published

run-env

Run package.json scripts suffixed with NODE_ENV.

CLI Usage

Assume the following package.json:

...
"scripts": {
  "build:dev": "...",
  "build:prod": "...",
  "build": "..."
},
...

This will run any script that ends with :${NODE_ENV}. If there is no match, it will also accept suffixes that match at least the first 3 characters of NODE_ENV (ex: build:dev will match NODE_ENV=development). As a final fallback, an exact match will be run.

yarn run-env build

# NODE_ENV=development -> yarn run build:dev
# NODE_ENV=production -> yarn run build:prod
# NODE_ENV=local -> yarn run build

Additionally, and environment variables listed in .env will be loaded before running.

Programmatic Usage

runEnv(script: string) => Promise<SpawnSyncReturns<Buffer>>;
import runEnv from "run-env";

runEnv("build");

Dependents (1)

Package Sidebar

Install

npm i @bconnorwhite/run-env

Weekly Downloads

9

Version

1.1.6

License

MIT

Unpacked Size

6.14 kB

Total Files

8

Last publish

Collaborators

  • bconnorwhite