Skip to content

Commit

Permalink
renamed runenv to by-node-env
Browse files Browse the repository at this point in the history
  • Loading branch information
shian15810 committed Jun 11, 2019
1 parent 0c0c95a commit b3c1173
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# runenv
# by-node-env

Run package.json scripts depending on `NODE_ENV`.

[![travis build](https://img.shields.io/travis/shian15810/runenv.svg)](https://travis-ci.org/shian15810/runenv)
[![version](https://img.shields.io/npm/v/runenv.svg)](http://npm.im/runenv)
[![downloads](https://img.shields.io/npm/dm/runenv.svg)](http://npm-stat.com/charts.html?package=runenv)
[![MIT License](https://img.shields.io/npm/l/runenv.svg)](http://opensource.org/licenses/MIT)
[![travis build](https://img.shields.io/travis/shian15810/by-node-env.svg)](https://travis-ci.org/shian15810/by-node-env)
[![version](https://img.shields.io/npm/v/by-node-env.svg)](http://npm.im/by-node-env)
[![downloads](https://img.shields.io/npm/dm/by-node-env.svg)](http://npm-stat.com/charts.html?package=by-node-env)
[![MIT License](https://img.shields.io/npm/l/by-node-env.svg)](http://opensource.org/licenses/MIT)

## Installation

Install with npm:

```sh
npm install runenv
npm install by-node-env
```

Install with Yarn:

```sh
yarn add runenv
yarn add by-node-env
```

## Features

- [x] Defaults `NODE_ENV` to `development`.
- [x] Customize `process.env` runenvironment.
- [x] Customize `process.env` by-node-environment.
- [x] Clearer, concise scripts.
- [x] No more Bash-scripting in `package.json`.
- [x] Works on Linux, macOS and Windows.
Expand All @@ -37,30 +37,30 @@ yarn add runenv

```js
{
// Processes spawned by `runenv` inherit environment-specific
// Processes spawned by `by-node-env` inherit environment-specific
// variables, if defined.
"runenv": {
"by-node-env": {
"production": {
"DOCKER_USER": "my",
"DOCKER_REPO": "project"
}
},
"scripts": {
// If NODE_ENV is missing, defaults to "development".
"build": "runenv",
"build": "by-node-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": "runenv",
"deploy": "by-node-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": "runenv",
"start": "by-node-env",

"start:development": "npm run build:development",

Expand All @@ -71,7 +71,7 @@ yarn add runenv
"start:staging": "start-cluster build/server/server.js",

// Explicitly set NODE_ENV, which is helpful in CI.
"test": "NODE_ENV=test runenv",
"test": "NODE_ENV=test by-node-env",

"test:test": "mocha"
}
Expand All @@ -80,7 +80,7 @@ yarn add runenv

## Note

`runenv` is essentially a clone of [`per-env`](https://www.npmjs.com/package/per-env) with some notable fixes in 1.0.0:
`by-node-env` is essentially a clone of [`per-env`](https://www.npmjs.com/package/per-env) with some notable fixes in 1.0.0:

- Windows compatibility.
- Yarn compatibility.
4 changes: 2 additions & 2 deletions bin/runenv → bin/by-node-env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var env = Object.assign(
// Default NODE_ENV
{ NODE_ENV: NODE_ENV},
// Override with package.json custom env variables
(pkg && pkg["runenv"] && pkg["runenv"][NODE_ENV]) || {},
(pkg && pkg["by-node-env"] && pkg["by-node-env"][NODE_ENV]) || {},

// Explicit env takes precedence
process.env
Expand All @@ -32,7 +32,7 @@ var args = [
"run",
script
].concat(
// Extra arguments after "runenv"
// Extra arguments after "by-node-env"
process.argv.slice(2)
);

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"name": "runenv",
"name": "by-node-env",
"version": "1.0.0",
"description": "Run package.json scripts depending on NODE_ENV.",
"bin": {
"runenv": "./bin/runenv"
"by-node-env": "./bin/by-node-env"
},
"scripts": {
"test": "NODE_ENV=development ./bin/runenv && NODE_ENV=test ./bin/runenv",
"test": "NODE_ENV=development ./bin/by-node-env && NODE_ENV=test ./bin/by-node-env",
"pretest:development": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}",
"test:development": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}",
"posttest:development": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}",
"pretest:test": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}",
"test:test": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}",
"posttest:test": "echo ${npm_lifecycle_event} ${CUSTOM_VALUE}"
},
"runenv": {
"by-node-env": {
"development": {
"CUSTOM_VALUE": "dev"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/shian15810/runenv.git"
"url": "git+https://github.com/shian15810/by-node-env.git"
},
"keywords": [
"build",
Expand Down Expand Up @@ -60,7 +60,7 @@
"process",
"prod",
"production",
"runenv",
"by-node-env",
"run",
"script",
"scripts",
Expand All @@ -76,9 +76,9 @@
"author": "Chuah Chee Shian <shian15810@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/shian15810/runenv/issues"
"url": "https://github.com/shian15810/by-node-env/issues"
},
"homepage": "https://github.com/shian15810/runenv#readme",
"homepage": "https://github.com/shian15810/by-node-env#readme",
"dependencies": {
"cross-spawn": "^6.0.5"
}
Expand Down

0 comments on commit b3c1173

Please sign in to comment.