@dotenvx/dotenvx
Advanced tools
Comparing version 1.28.0 to 1.29.0
@@ -5,4 +5,10 @@ # Changelog | ||
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.28.0...main) | ||
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.29.0...main) | ||
## [1.29.0](https://github.com/dotenvx/dotenvx/compare/v1.28.0...v1.29.0) | ||
### Added | ||
* add `--ignore` flag to suppress specified errors. example: `dotenvx run --ignore=MISSING_ENV_FILE` ([#485](https://github.com/dotenvx/dotenvx/pull/485)) | ||
## [1.28.0](https://github.com/dotenvx/dotenvx/compare/v1.27.0...v1.28.0) | ||
@@ -9,0 +15,0 @@ |
{ | ||
"version": "1.28.0", | ||
"version": "1.29.0", | ||
"name": "@dotenvx/dotenvx", | ||
@@ -4,0 +4,0 @@ "description": "a better dotenv–from the creator of `dotenv`", |
@@ -987,2 +987,14 @@ [![dotenvx](https://dotenvx.com/better-banner.png)](https://dotenvx.com) | ||
</details> | ||
* <details><summary>`run --ignore`</summary><br> | ||
Ignore errors like `MISSING_ENV_FILE`. | ||
```sh | ||
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js | ||
$ dotenvx run -f .env.missing --ignore=MISSING_ENV_FILE -- node index.js | ||
... | ||
``` | ||
</details> | ||
* <details><summary>`run --convention=nextjs`</summary><br> | ||
@@ -1699,8 +1711,16 @@ | ||
$ dotenvx ext gitignore | ||
creating .gitignore | ||
appending .env* to .gitignore | ||
done | ||
✔ ignored .env* (.gitignore) | ||
``` | ||
</details> | ||
* <details><summary>`ext gitignore --pattern`</summary><br> | ||
Gitignore specific pattern(s) of `.env` files. | ||
```sh | ||
$ dotenvx ext gitignore --pattern .env.keys | ||
✔ ignored .env.keys (.gitignore) | ||
``` | ||
</details> | ||
* <details><summary>`ext precommit`</summary><br> | ||
@@ -1712,3 +1732,3 @@ | ||
$ dotenvx ext precommit | ||
[dotenvx][precommit] success | ||
[dotenvx][precommit] .env files (1) protected (encrypted or gitignored) | ||
``` | ||
@@ -1723,3 +1743,3 @@ | ||
$ dotenvx ext precommit --install | ||
[dotenvx][precommit] dotenvx precommit installed [.git/hooks/pre-commit] | ||
[dotenvx][precommit] dotenvx ext precommit installed [.git/hooks/pre-commit] | ||
``` | ||
@@ -1735,2 +1755,3 @@ | ||
```sh | ||
# Dockerfile | ||
RUN curl -fsS https://dotenvx.sh | sh | ||
@@ -1788,2 +1809,4 @@ | ||
It defaults to looking for a `.env` file. | ||
</details> | ||
@@ -1820,3 +1843,3 @@ * <details><summary>`config(path: ['.env.local', '.env'])` - multiple files</summary><br> | ||
User `overload` to overwrite the prior set value. | ||
Use `overload` to overwrite the prior set value. | ||
@@ -1869,2 +1892,25 @@ ```ini | ||
</details> | ||
* <details><summary>`config(ignore:)` - ignore</summary><br> | ||
Use `ignore` to suppress specific errors like `MISSING_ENV_FILE`. | ||
```ini | ||
# .env | ||
HELLO="World" | ||
``` | ||
```js | ||
// index.js | ||
require('@dotenvx/dotenvx').config({path: ['.env.missing', '.env'], ignore: ['MISSING_ENV_FILE']}) | ||
console.log(`Hello ${process.env.HELLO}`) | ||
``` | ||
```sh | ||
$ node index.js | ||
[dotenvx@1.24.5] injecting env (1) from .env.local, .env | ||
Hello World | ||
``` | ||
</details> | ||
* <details><summary>`parse(src)`</summary><br> | ||
@@ -1871,0 +1917,0 @@ |
@@ -16,2 +16,4 @@ const { logger } = require('./../../shared/logger') | ||
const ignore = options.ignore || [] | ||
let envs = [] | ||
@@ -31,2 +33,6 @@ // handle shorthand conventions - like --convention=nextjs | ||
if (ignore.includes(error.code)) { | ||
continue // ignore error | ||
} | ||
console.error(error.message) | ||
@@ -33,0 +39,0 @@ if (error.help) { |
@@ -17,2 +17,4 @@ const path = require('path') | ||
const ignore = options.ignore || [] | ||
if (commandArgs.length < 1) { | ||
@@ -66,2 +68,7 @@ const hasSeparator = process.argv.indexOf('--') !== -1 | ||
if (ignore.includes(error.code)) { | ||
logger.verbose(`ignored: ${error.message}`) | ||
continue // ignore error | ||
} | ||
if (error.code === 'MISSING_ENV_FILE') { | ||
@@ -68,0 +75,0 @@ if (!options.convention) { // do not output error for conventions (too noisy) |
@@ -63,2 +63,3 @@ #!/usr/bin/env node | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])') | ||
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)') | ||
.action(function (...args) { | ||
@@ -81,2 +82,3 @@ this.envs = envs | ||
.option('--convention <name>', 'load a .env convention (available conventions: [\'nextjs\'])') | ||
.option('--ignore <errorCodes...>', 'error code(s) to ignore (example: --ignore=MISSING_ENV_FILE)') | ||
.option('-a, --all', 'include all machine envs as well') | ||
@@ -83,0 +85,0 @@ .option('-pp, --pretty-print', 'pretty print output') |
@@ -18,3 +18,3 @@ const truncate = require('./truncate') | ||
const message = `[${code}] missing ${this.envFilepath} file (${this.filepath})` | ||
const help = `[${code}] ? add one with [echo "HELLO=World" > ${this.envFilepath}]` | ||
const help = `[${code}] https://github.com/dotenvx/dotenvx/issues/484` | ||
@@ -21,0 +21,0 @@ const e = new Error(message) |
@@ -31,2 +31,5 @@ // @ts-check | ||
// ignore | ||
const ignore = options.ignore || [] | ||
// strict | ||
@@ -90,2 +93,6 @@ const strict = options.strict | ||
if (ignore.includes(error.code)) { | ||
continue // ignore error | ||
} | ||
lastError = error // surface later in { error } | ||
@@ -97,3 +104,3 @@ | ||
if (error.help) { | ||
logger.help(error.help) | ||
console.error(error.help) | ||
} | ||
@@ -104,3 +111,3 @@ } | ||
if (error.help) { | ||
logger.help(error.help) | ||
console.error(error.help) | ||
} | ||
@@ -107,0 +114,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229225
3696
2032