Run package.json scripts suffixed with NODE_ENV.
npm install @bconnorwhite/run-envAssume the following package.json:
``json`
...
"scripts": {
"build:dev": "...",
"build:prod": "...",
"build": "..."
},
...:${NODE_ENV}
This will run any script that ends with . 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.`bash
yarn run-env build
Additionally, and environment variables listed in
.env will be loaded before running.#### Programmatic Usage
`ts
runEnv(script: string) => Promise>;
``ts
import runEnv from "run-env";runEnv("build");
``