Skip to content

Commit

Permalink
installed prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
shian15810 committed Jul 30, 2019
1 parent a4483bf commit 2ea45e0
Show file tree
Hide file tree
Showing 24 changed files with 550 additions and 209 deletions.
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.editorconfig
/.env
/.gitignore
/.prettierignore
/.rts2_cache_*
/dist
/LICENSE
/yarn.lock
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"search.exclude": {
"dist": true
}
}
"search.exclude": {
"dist": true
}
}
24 changes: 12 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@

## 1.0.0 (2019-06-11)

- Cloned original repository from [**github:ericclemmons/per-env**](https://github.com/ericclemmons/per-env).
- Added support for **Windows** with [**cross-spawn**](https://www.npmjs.com/package/cross-spawn).
- Added support for **Yarn** by detecting `process.env.npm_execpath`.
- Cloned original repository from [**github:ericclemmons/per-env**](https://github.com/ericclemmons/per-env).
- Added support for **Windows** with [**cross-spawn**](https://www.npmjs.com/package/cross-spawn).
- Added support for **Yarn** by detecting `process.env.npm_execpath`.

## 1.0.1 (2019-06-12)

- Fixed some typos.
- Fixed some typos.

## 1.0.2 (2019-06-12)

- Updated README.
- Updated README.

## 1.0.3 (2019-06-12)

- Refactored some codes.
- Refactored some codes.

## 1.1.0 (2019-06-14)

- Changed support of **Yarn** from `process.env.npm_execpath` to [**which-pm-runs**](https://www.npmjs.com/package/which-pm-runs) which detects `process.env.npm_config_user_agent`, with additional **pnpm** support.
- Changed support of **Yarn** from `process.env.npm_execpath` to [**which-pm-runs**](https://www.npmjs.com/package/which-pm-runs) which detects `process.env.npm_config_user_agent`, with additional **pnpm** support.

## 1.1.1 (2019-06-17)

- Supported fallback to `process.env.npm_execpath` if `process.env.npm_config_user_agent` by [**which-pm-runs**](https://www.npmjs.com/package/which-pm-runs) is `undefined`.
- Supported fallback to `process.env.npm_execpath` if `process.env.npm_config_user_agent` by [**which-pm-runs**](https://www.npmjs.com/package/which-pm-runs) is `undefined`.

## 1.2.0 (2019-06-19)

- Defaulted `NODE_ENV` to defined `NODE_ENV` in **.env** file if it is found in `process.cwd()`. `.env` file is parsed using [**dotenv**](https://www.npmjs.com/package/dotenv).
- Defaulted `NODE_ENV` to defined `NODE_ENV` in **.env** file if it is found in `process.cwd()`. `.env` file is parsed using [**dotenv**](https://www.npmjs.com/package/dotenv).

## 1.3.0 (2019-06-26)

- Solved some testing issues on **Windows**.
- Restructured repository.
- Replaced **Yarn** with **npm**.
- Solved some testing issues on **Windows**.
- Restructured repository.
- Replaced **Yarn** with **npm**.
118 changes: 59 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ yarn add by-node-env

## Features

- [x] Read `NODE_ENV` from `process.env`.
- [x] Read `NODE_ENV` from **.env** file.
- [x] Defaults `NODE_ENV` to `development`.
- [x] Customize `process.env` for each `NODE_ENV`.
- [x] Clearer, concise **scripts** in **package.json**.
- [x] No more **Bash** scripting in **package.json**.
- [x] Works on **Linux**, **macOS**, and **Windows**.
- [x] Compatible with **npm**, **pnpm**, and **Yarn**.
- [x] Consistent workflow for any `NODE_ENV`:
1. `npm install` or `pnpm install` or `yarn install`.
2. `npm start` or `pnpm start` or `yarn start`.
- [x] Read `NODE_ENV` from `process.env`.
- [x] Read `NODE_ENV` from **.env** file.
- [x] Defaults `NODE_ENV` to `development`.
- [x] Customize `process.env` for each `NODE_ENV`.
- [x] Clearer, concise **scripts** in **package.json**.
- [x] No more **Bash** scripting in **package.json**.
- [x] Works on **Linux**, **macOS**, and **Windows**.
- [x] Compatible with **npm**, **pnpm**, and **Yarn**.
- [x] Consistent workflow for any `NODE_ENV`:
1. `npm install` or `pnpm install` or `yarn install`.
2. `npm start` or `pnpm start` or `yarn start`.

## Problem

Expand All @@ -51,16 +51,16 @@ The **package.json** might look like this for those situations mentioned above:

```json
{
"scripts": {
"watch": "webpack -d --watch",
"build": "webpack -p",
"scripts": {
"watch": "webpack -d --watch",
"build": "webpack -p",

"dev": "nodemon src",
"prod": "node dist",
"dev": "nodemon src",
"prod": "node dist",

"serve": "npm run watch & npm run dev",
"start": "npm build && npm run prod"
}
"serve": "npm run watch & npm run dev",
"start": "npm build && npm run prod"
}
}
```

Expand All @@ -72,21 +72,21 @@ Working on multiple projects with different commands can be very confusing and f

```json
{
"scripts": {
"build": "by-node-env",
"scripts": {
"build": "by-node-env",

"build:development": "webpack -d --watch",
"build:production": "webpack -p",
"build:development": "webpack -d --watch",
"build:production": "webpack -p",

"start": "by-node-env",
"start": "by-node-env",

"start:development": "npm build & nodemon src",
"start:production": "npm build && node dist"
}
"start:development": "npm build & nodemon src",
"start:production": "npm build && node dist"
}
}
```

`npm build` and `npm start` have long been the de facto commands to *build* and *start* a **Node.js** application, respectively.
`npm build` and `npm start` have long been the de facto commands to _build_ and _start_ a **Node.js** application, respectively.

Besides that, `NODE_ENV` should always be explicitly set as an environment variable for best practice. A lot of popular frameworks expect `NODE_ENV` to be set as well.

Expand Down Expand Up @@ -114,12 +114,12 @@ The resolved `NODE_ENV` is available as `process.env.NODE_ENV` in your applicati

```jsonc
{
"scripts": {
"start": "by-node-env", // 1
"scripts": {
"start": "by-node-env", // 1

"start:development": "ts-node src", // 2a
"start:production": "ts-node-dev src" // 2b
}
"start:development": "ts-node src", // 2a
"start:production": "ts-node-dev src" // 2b
}
}
```

Expand All @@ -139,12 +139,12 @@ NODE_ENV=production

```jsonc
{
"scripts": {
"start": "by-node-env", // 1
"scripts": {
"start": "by-node-env", // 1

"start:development": "ts-node src", // 2a
"start:production": "ts-node-dev src" // 2b
}
"start:development": "ts-node src", // 2a
"start:production": "ts-node-dev src" // 2b
}
}
```

Expand All @@ -158,36 +158,36 @@ NODE_ENV=production

```jsonc
{
"scripts": {
// If NODE_ENV is missing, defaults to "development".
"build": "by-node-env",
"scripts": {
// If NODE_ENV is missing, defaults to "development".
"build": "by-node-env",

"build:development": "webpack -d --watch",
"build:production": "webpack -p",
"build:staging": "webpack -p",
"build:development": "webpack -d --watch",
"build:production": "webpack -p",
"build:staging": "webpack -p",

// Deployment will not work unless NODE_ENV=production is explicitly set.
"deploy": "by-node-env",
// Deployment will not work unless NODE_ENV=production is explicitly set.
"deploy": "by-node-env",

"predeploy:production": "docker build -t ${DOCKER_USER}/${DOCKER_PROJECT} .",
"deploy:production": "docker push ${DOCKER_USER}/${DOCKER_PROJECT}",
"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": "by-node-env",
// "npm start" is _the_ command to start the server across all environments.
"start": "by-node-env",

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

"prestart:production": "npm run build",
"start:production": "start-cluster build/server/server.js",
"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",
"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 by-node-env",
// Explicitly set NODE_ENV, which is helpful in CI.
"test": "NODE_ENV=test by-node-env",

"test:test": "mocha"
}
"test:test": "mocha"
}
}
```

Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2ea45e0

Please sign in to comment.