https://github.com/ericclemmons/per-env
Clean up your package.json with per-NODE_ENV npm scripts
https://github.com/ericclemmons/per-env
Last synced: 18 days ago
JSON representation
Clean up your package.json with per-NODE_ENV npm scripts
- Host: GitHub
- URL: https://github.com/ericclemmons/per-env
- Owner: ericclemmons
- License: mit
- Created: 2016-02-26T03:09:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T10:34:46.000Z (almost 3 years ago)
- Last Synced: 2025-04-06T07:15:41.765Z (19 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 134
- Watchers: 2
- Forks: 18
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# per-env
> Clean up your `package.json` with per-`NODE_ENV` npm scripts.
[](https://travis-ci.org/ericclemmons/per-env)
[](http://npm.im/per-env)
[](http://npm-stat.com/charts.html?package=per-env)
[](http://opensource.org/licenses/MIT)### Features
- [x] Defaults `NODE_ENV` to `development`.
- [x] Customize `process.env` per-environment.
- [x] Clearer, concise scripts.
- [x] No more Bash-scripting in `package.json`.
- [x] Simplify your workflow:
1. `npm install`
2. `npm start`### Example
```js
{
// Processes spawned by `per-env` inherit environment-specific
// variables, if defined.
"per-env": {
"production": {
"DOCKER_USER": "my",
"DOCKER_REPO": "project"
}
},
"scripts": {
// If NODE_ENV is missing, defaults to "development".
"build": "per-env","build:development": "webpack -d --watch",
"build:staging": "webpack -p",
"build:production": "webpack -p",// Deployment won't work unless NODE_ENV=production is explicitly set.
"deploy": "per-env","predeploy:production": "docker build -t ${DOCKER_USER}/${DOCKER_PROJECT} .",
"deploy:production": "docker push ${DOCKER_USER}/${DOCKER_PROJECT}",// "npm start" is _the_ command to start the server across all environments.
"start": "per-env","start:development": "npm run build:development",
"prestart:production": "npm run build",
"start:production": "start-cluster build/server/server.js","prestart:staging": "npm run build",
"start:staging": "start-cluster build/server/server.js",// Explicitly set NODE_ENV, which is helpful in CI.
"test": "NODE_ENV=test per-env","test:test": "mocha"
}
}
```### Installation
```shell
$ npm install --save per-env
```### License
> MIT License 2016 © Eric Clemmons