mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
Convert over to using ts-standard
- Removed all the various eslint dependencies and added ts-standard - Updated Readme file with some minor changes - Updated dist folder to have one level again
This commit is contained in:
parent
f5e2e33939
commit
bbc4b78ad2
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "standard-with-typescript",
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"project": "./tsconfig.json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
30
README.md
30
README.md
@ -3,18 +3,22 @@
|
|||||||
[](https://www.npmjs.com/package/env-cmd)
|
[](https://www.npmjs.com/package/env-cmd)
|
||||||
[](https://www.npmjs.com/package/env-cmd)
|
[](https://www.npmjs.com/package/env-cmd)
|
||||||
[](https://www.npmjs.com/package/env-cmd)
|
[](https://www.npmjs.com/package/env-cmd)
|
||||||
[](http://standardjs.com/) [](https://greenkeeper.io/)
|
[](https://github.com/toddbluhm/ts-standard)
|
||||||
|
[](https://greenkeeper.io/)
|
||||||
|
|
||||||
# env-cmd
|
# env-cmd
|
||||||
|
|
||||||
A simple node program for executing commands using an environment from an env file.
|
A simple node program for executing commands using an environment from an env file.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
`npm install env-cmd` or `npm install -g env-cmd`
|
`npm install env-cmd` or `npm install -g env-cmd`
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
**Environment file `./.env`**
|
**Environment file `./.env`**
|
||||||
```
|
|
||||||
|
```text
|
||||||
# This is a comment
|
# This is a comment
|
||||||
ENV1=THANKS
|
ENV1=THANKS
|
||||||
ENV2=FOR ALL
|
ENV2=FOR ALL
|
||||||
@ -22,6 +26,7 @@ ENV3=THE FISH
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Package.json**
|
**Package.json**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -31,20 +36,24 @@ ENV3=THE FISH
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Terminal**
|
**Terminal**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./node_modules/.bin/env-cmd node index.js
|
./node_modules/.bin/env-cmd node index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using custom env file path
|
## Using custom env file path
|
||||||
|
|
||||||
To use a custom env filename or path, pass the `-f` flag. This is a major breaking change from prior versions < 9.0.0
|
To use a custom env filename or path, pass the `-f` flag. This is a major breaking change from prior versions < 9.0.0
|
||||||
|
|
||||||
**Terminal**
|
**Terminal**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./node_modules/.bin/env-cmd -f ./custom/path/.env node index.js
|
./node_modules/.bin/env-cmd -f ./custom/path/.env node index.js
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📜 Help
|
## 📜 Help
|
||||||
```
|
|
||||||
|
```text
|
||||||
Usage: _ [options] <command> [...args]
|
Usage: _ [options] <command> [...args]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
@ -87,6 +96,7 @@ are found.
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Terminal**
|
**Terminal**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./node_modules/.bin/env-cmd -e production node index.js
|
./node_modules/.bin/env-cmd -e production node index.js
|
||||||
# Or for multiple environments (where `production` vars override `test` vars,
|
# Or for multiple environments (where `production` vars override `test` vars,
|
||||||
@ -110,6 +120,7 @@ Executes the command within a new shell environment. This is useful if you want
|
|||||||
commands together that share the same environment variables.
|
commands together that share the same environment variables.
|
||||||
|
|
||||||
**Terminal**
|
**Terminal**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./node_modules/.bin/env-cmd -f ./test/.env --use-shell "npm run lint && npm test"
|
./node_modules/.bin/env-cmd -f ./test/.env --use-shell "npm run lint && npm test"
|
||||||
```
|
```
|
||||||
@ -122,6 +133,7 @@ files are also supported using `.js` file extension and resolving to an object w
|
|||||||
names (`{ production: { ENV_VAR_NAME: value, ... } }`).
|
names (`{ production: { ENV_VAR_NAME: value, ... } }`).
|
||||||
|
|
||||||
**Terminal**
|
**Terminal**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./node_modules/.bin/env-cmd -f ./async-file.js node index.js
|
./node_modules/.bin/env-cmd -f ./async-file.js node index.js
|
||||||
```
|
```
|
||||||
@ -134,6 +146,7 @@ the examples repo [env-cmd-examples](https://github.com/toddbluhm/env-cmd-exampl
|
|||||||
## Environment File Formats
|
## Environment File Formats
|
||||||
|
|
||||||
These are the currently accepted environment file formats. If any other formats are desired please create an issue.
|
These are the currently accepted environment file formats. If any other formats are desired please create an issue.
|
||||||
|
|
||||||
- `.env` as `key=value`
|
- `.env` as `key=value`
|
||||||
- `.env.json` Key/value pairs as JSON
|
- `.env.json` Key/value pairs as JSON
|
||||||
- `.env.js` JavaScript file exporting an `object` or a `Promise` that resolves to an `object`
|
- `.env.js` JavaScript file exporting an `object` or a `Promise` that resolves to an `object`
|
||||||
@ -158,8 +171,10 @@ Working Directory = `/Users/test/Development/app`
|
|||||||
## ⚒ API Usage
|
## ⚒ API Usage
|
||||||
|
|
||||||
### `EnvCmd`
|
### `EnvCmd`
|
||||||
|
|
||||||
A function that executes a given command in a new child process with the given environment and options
|
A function that executes a given command in a new child process with the given environment and options
|
||||||
- **`options`** { `object` }
|
|
||||||
|
- **`options`** { `object` }
|
||||||
- **`command`** { `string` }: The command to execute (`node`, `mocha`, ...)
|
- **`command`** { `string` }: The command to execute (`node`, `mocha`, ...)
|
||||||
- **`commandArgs`** { `string[]` }: List of arguments to pass to the `command` (`['-R', 'Spec']`)
|
- **`commandArgs`** { `string[]` }: List of arguments to pass to the `command` (`['-R', 'Spec']`)
|
||||||
- **`envFile`** { `object` }
|
- **`envFile`** { `object` }
|
||||||
@ -174,15 +189,17 @@ A function that executes a given command in a new child process with the given e
|
|||||||
- **Returns** { `Promise<object>` }: key is env var name and value is the env var value
|
- **Returns** { `Promise<object>` }: key is env var name and value is the env var value
|
||||||
|
|
||||||
### `GetEnvVars`
|
### `GetEnvVars`
|
||||||
|
|
||||||
A function that parses environment variables from a `.env` or a `.rc` file
|
A function that parses environment variables from a `.env` or a `.rc` file
|
||||||
- **`options`** { `object` }
|
|
||||||
|
- **`options`** { `object` }
|
||||||
- **`envFile`** { `object` }
|
- **`envFile`** { `object` }
|
||||||
- **`filePath`** { `string` }: Custom path to .env file to read from (defaults to: `./.env`)
|
- **`filePath`** { `string` }: Custom path to .env file to read from (defaults to: `./.env`)
|
||||||
- **`fallback`** { `boolean` }: Should fall back to default `./.env` file if custom path does not exist
|
- **`fallback`** { `boolean` }: Should fall back to default `./.env` file if custom path does not exist
|
||||||
- **`rc`** { `object` }
|
- **`rc`** { `object` }
|
||||||
- **`environments`** { `string[]` }: List of environment to read from the `.rc` file
|
- **`environments`** { `string[]` }: List of environment to read from the `.rc` file
|
||||||
- **`filePath`** { `string` }: Custom path to the `.rc` file (defaults to: `./.env-cmdrc(|.js|.json)`)
|
- **`filePath`** { `string` }: Custom path to the `.rc` file (defaults to: `./.env-cmdrc(|.js|.json)`)
|
||||||
- **Returns** { `Promise<object>` }: key is env var name and value is the env var value
|
- **Returns** { `Promise<object>` }: key is env var name and value is the env var value
|
||||||
|
|
||||||
## Why
|
## Why
|
||||||
|
|
||||||
@ -208,6 +225,7 @@ same `cross-spawn` lib underneath too).
|
|||||||
- Anton Versal
|
- Anton Versal
|
||||||
|
|
||||||
## 📋 Contributing Guide
|
## 📋 Contributing Guide
|
||||||
|
|
||||||
I welcome all pull requests. Please make sure you add appropriate test cases for any features
|
I welcome all pull requests. Please make sure you add appropriate test cases for any features
|
||||||
added. Before opening a PR please make sure to run the following scripts:
|
added. Before opening a PR please make sure to run the following scripts:
|
||||||
|
|
||||||
|
|||||||
0
dist/src/env-cmd.js → dist/env-cmd.js
vendored
0
dist/src/env-cmd.js → dist/env-cmd.js
vendored
0
dist/src/index.d.ts → dist/index.d.ts
vendored
0
dist/src/index.d.ts → dist/index.d.ts
vendored
0
dist/src/index.js → dist/index.js
vendored
0
dist/src/index.js → dist/index.js
vendored
0
dist/src/spawn.d.ts → dist/spawn.d.ts
vendored
0
dist/src/spawn.d.ts → dist/spawn.d.ts
vendored
0
dist/src/spawn.js → dist/spawn.js
vendored
0
dist/src/spawn.js → dist/spawn.js
vendored
0
dist/src/types.d.ts → dist/types.d.ts
vendored
0
dist/src/types.d.ts → dist/types.d.ts
vendored
0
dist/src/types.js → dist/types.js
vendored
0
dist/src/types.js → dist/types.js
vendored
0
dist/src/utils.d.ts → dist/utils.d.ts
vendored
0
dist/src/utils.d.ts → dist/utils.d.ts
vendored
0
dist/src/utils.js → dist/utils.js
vendored
0
dist/src/utils.js → dist/utils.js
vendored
23
package.json
23
package.json
@ -2,8 +2,8 @@
|
|||||||
"name": "env-cmd",
|
"name": "env-cmd",
|
||||||
"version": "10.0.0",
|
"version": "10.0.0",
|
||||||
"description": "Executes a command using the environment variables in an env file",
|
"description": "Executes a command using the environment variables in an env file",
|
||||||
"main": "dist/src/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/src/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
},
|
},
|
||||||
@ -13,9 +13,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha -r ts-node/register ./test/**/*.ts",
|
"test": "mocha -r ts-node/register ./test/**/*.ts",
|
||||||
"test-cover": "nyc --reporter=lcov --reporter=text npm test",
|
"test-cover": "nyc --reporter=lcov --reporter=text npm test",
|
||||||
"test-lint": "eslint ./src/**/*.ts ./test/**/*.ts",
|
|
||||||
"coveralls": "coveralls < coverage/lcov.info",
|
"coveralls": "coveralls < coverage/lcov.info",
|
||||||
"lint": "eslint --fix ./src/**/*.ts ./test/**/*.ts && tsc --noEmit",
|
"lint": "ts-standard --fix && tsc --noEmit",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"watch": "tsc -w"
|
"watch": "tsc -w"
|
||||||
},
|
},
|
||||||
@ -57,21 +56,13 @@
|
|||||||
"@types/mocha": "^5.0.0",
|
"@types/mocha": "^5.0.0",
|
||||||
"@types/node": "^12.0.0",
|
"@types/node": "^12.0.0",
|
||||||
"@types/sinon": "^7.0.0",
|
"@types/sinon": "^7.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.0.0",
|
|
||||||
"@typescript-eslint/parser": "^2.0.0",
|
|
||||||
"chai": "^4.0.0",
|
"chai": "^4.0.0",
|
||||||
"coveralls": "^3.0.0",
|
"coveralls": "^3.0.0",
|
||||||
"eslint": "^6.0.0",
|
|
||||||
"eslint-config-standard": "^14.0.0",
|
|
||||||
"eslint-config-standard-with-typescript": "toddbluhm/eslint-config-standard-with-typescript#compiled",
|
|
||||||
"eslint-plugin-import": "^2.0.0",
|
|
||||||
"eslint-plugin-node": "^9.0.0",
|
|
||||||
"eslint-plugin-promise": "^4.0.0",
|
|
||||||
"eslint-plugin-standard": "^4.0.0",
|
|
||||||
"mocha": "^6.0.0",
|
"mocha": "^6.0.0",
|
||||||
"nyc": "^14.0.0",
|
"nyc": "^14.0.0",
|
||||||
"sinon": "^7.0.0",
|
"sinon": "^7.0.0",
|
||||||
"ts-node": "^8.0.0",
|
"ts-node": "^8.0.0",
|
||||||
|
"ts-standard": "^1.0.0",
|
||||||
"typescript": "^3.0.0"
|
"typescript": "^3.0.0"
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
@ -90,5 +81,11 @@
|
|||||||
],
|
],
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"instrument": true
|
"instrument": true
|
||||||
|
},
|
||||||
|
"ts-standard": {
|
||||||
|
"project": "./tsconfig.eslint.json",
|
||||||
|
"ignore": [
|
||||||
|
"dist"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
module.exports = new Promise((resolve) => {
|
module.exports = new Promise((resolve) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resolve({
|
resolve({
|
||||||
'THANKS': 'FOR ALL THE FISH',
|
THANKS: 'FOR ALL THE FISH',
|
||||||
'ANSWER': 0
|
ANSWER: 0
|
||||||
})
|
})
|
||||||
}, 200)
|
}, 200)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
'THANKS': 'FOR ALL THE FISH',
|
THANKS: 'FOR ALL THE FISH',
|
||||||
'ANSWER': 0,
|
ANSWER: 0,
|
||||||
'GALAXY': 'hitch\nhiking'
|
GALAXY: 'hitch\nhiking'
|
||||||
}
|
}
|
||||||
|
|||||||
12
tsconfig.eslint.json
Normal file
12
tsconfig.eslint.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*",
|
||||||
|
"test/**/*",
|
||||||
|
"bin/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -10,7 +10,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*",
|
"./src/**/*"
|
||||||
"./test/**/*"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user