@dotenvx/dotenvx 1.22.0 → 1.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.22.0...main)
5
+ ## [Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.22.2...main)
6
+
7
+ ## 1.22.2
8
+
9
+ ### Changed
10
+
11
+ * more lenient handling of `--` separator and better error messaging when flags are ambiguous ([#438](https://github.com/dotenvx/dotenvx/pull/438))
12
+
13
+ ## 1.22.1
14
+
15
+ ### Changed
16
+
17
+ * 🐞 patch loading order issue with single quotes ([#436](https://github.com/dotenvx/dotenvx/pull/436))
6
18
 
7
19
  ## 1.22.0
8
20
 
package/README.md CHANGED
@@ -867,7 +867,7 @@ More examples
867
867
 
868
868
  ```sh
869
869
  $ touch .env.ci
870
- $ dotenvx set HELLO "ci encrypted" -f .env.production
870
+ $ dotenvx set HELLO "ci encrypted" -f .env.ci
871
871
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
872
872
 
873
873
  # check .env.keys for your privateKey
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.22.0",
2
+ "version": "1.22.2",
3
3
  "name": "@dotenvx/dotenvx",
4
4
  "description": "a better dotenv–from the creator of `dotenv`",
5
5
  "author": "@motdotla",
@@ -13,6 +13,19 @@ async function run () {
13
13
  const options = this.opts()
14
14
  logger.debug(`options: ${JSON.stringify(options)}`)
15
15
 
16
+ if (commandArgs.length < 1) {
17
+ const hasSeparator = process.argv.indexOf('--') !== -1
18
+
19
+ if (hasSeparator) {
20
+ console.error('missing command after [dotenvx run --]. try [dotenvx run -- yourcommand]')
21
+ } else {
22
+ const realExample = options.envFile[0] || '.env'
23
+ console.error(`ambiguous command due to missing '--' separator. try [dotenvx run -f ${realExample} -- yourcommand]`)
24
+ }
25
+
26
+ process.exit(1)
27
+ }
28
+
16
29
  try {
17
30
  let envs = []
18
31
  // handle shorthand conventions - like --convention=nextjs
@@ -106,17 +119,7 @@ async function run () {
106
119
  }
107
120
  }
108
121
 
109
- // Extract command and arguments after '--'
110
- const commandIndex = process.argv.indexOf('--')
111
- if (commandIndex === -1 || commandIndex === process.argv.length - 1) {
112
- logger.error('missing command after [dotenvx run --]')
113
- logger.error('')
114
- logger.error(' get help: [dotenvx help run]')
115
- logger.error(' or try: [dotenvx run -- npm run dev]')
116
- process.exit(1)
117
- } else {
118
- await executeCommand(commandArgs, process.env)
119
- }
122
+ await executeCommand(commandArgs, process.env)
120
123
  }
121
124
 
122
125
  module.exports = run
@@ -15,7 +15,7 @@ Try it:
15
15
  $ echo "HELLO=World" > .env
16
16
  $ echo "console.log('Hello ' + process.env.HELLO)" > index.js
17
17
 
18
- $ dotenvx run -- node index.js
18
+ $ dotenvx run -f .env -- node index.js
19
19
  [dotenvx] injecting env (1) from .env
20
20
  Hello World
21
21
  \`\`\`
@@ -20,6 +20,7 @@ function parseDecryptEvalExpand (src, privateKey = null, processEnv = process.en
20
20
  const parsed = dotenv.parse(src)
21
21
  const _quotes = quotes(src)
22
22
  const originalParsed = { ...parsed }
23
+ const originalProcessEnv = { ...processEnv }
23
24
  for (const key in parsed) {
24
25
  try {
25
26
  const decryptedValue = decryptValue(parsed[key], privateKey)
@@ -56,10 +57,11 @@ function parseDecryptEvalExpand (src, privateKey = null, processEnv = process.en
56
57
  warnings.push(warning(e, key, privateKey))
57
58
  }
58
59
  }
60
+
59
61
  for (const key in processEnv) {
60
62
  // unset eval and expansion for single quotes
61
63
  if (_quotes[key] === "'") {
62
- processEnv[key] = originalParsed[key] // reset to original
64
+ processEnv[key] = originalProcessEnv[key] || originalParsed[key] // reset to original
63
65
  }
64
66
 
65
67
  try {