@dotenvx/dotenvx 1.22.1 → 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,13 @@
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.1...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))
6
12
 
7
13
  ## 1.22.1
8
14
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.22.1",
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
  \`\`\`