@optique/env 1.1.6 → 1.1.7

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/dist/index.cjs CHANGED
@@ -386,14 +386,16 @@ function bindEnv(parser, options) {
386
386
  },
387
387
  parse: (context) => {
388
388
  const annotations = (0, __optique_core_annotations.getAnnotations)(context.state);
389
- const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
389
+ const hadCliValue = isEnvBindState(context.state) && context.state.hasCliValue;
390
+ const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : (0, __optique_core_extension.inheritAnnotations)(context.state, parser.initialState) : context.state;
390
391
  const innerContext = innerState !== context.state ? {
391
392
  ...context,
392
393
  state: innerState
393
394
  } : context;
394
395
  const processResult = (result) => {
395
396
  if (result.success) {
396
- const cliConsumed = result.consumed.length > 0;
397
+ const terminatorOnly = result.consumed.length === 1 && result.consumed[0] === "--" && !context.optionsTerminated && result.next.optionsTerminated;
398
+ const cliConsumed = hadCliValue || result.consumed.length > 0 && !terminatorOnly;
397
399
  const nextState$1 = (0, __optique_core_extension.injectAnnotations)({
398
400
  [envBindStateKey]: true,
399
401
  hasCliValue: cliConsumed,
@@ -410,6 +412,11 @@ function bindEnv(parser, options) {
410
412
  };
411
413
  }
412
414
  if (result.consumed > 0) return result;
415
+ if (hadCliValue) return {
416
+ success: true,
417
+ next: context,
418
+ consumed: []
419
+ };
413
420
  const nextState = (0, __optique_core_extension.injectAnnotations)({
414
421
  [envBindStateKey]: true,
415
422
  hasCliValue: false
package/dist/index.js CHANGED
@@ -363,14 +363,16 @@ function bindEnv(parser, options) {
363
363
  },
364
364
  parse: (context) => {
365
365
  const annotations = getAnnotations(context.state);
366
- const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : parser.initialState : context.state;
366
+ const hadCliValue = isEnvBindState(context.state) && context.state.hasCliValue;
367
+ const innerState = isEnvBindState(context.state) ? context.state.hasCliValue ? context.state.cliState : inheritAnnotations(context.state, parser.initialState) : context.state;
367
368
  const innerContext = innerState !== context.state ? {
368
369
  ...context,
369
370
  state: innerState
370
371
  } : context;
371
372
  const processResult = (result) => {
372
373
  if (result.success) {
373
- const cliConsumed = result.consumed.length > 0;
374
+ const terminatorOnly = result.consumed.length === 1 && result.consumed[0] === "--" && !context.optionsTerminated && result.next.optionsTerminated;
375
+ const cliConsumed = hadCliValue || result.consumed.length > 0 && !terminatorOnly;
374
376
  const nextState$1 = injectAnnotations({
375
377
  [envBindStateKey]: true,
376
378
  hasCliValue: cliConsumed,
@@ -387,6 +389,11 @@ function bindEnv(parser, options) {
387
389
  };
388
390
  }
389
391
  if (result.consumed > 0) return result;
392
+ if (hadCliValue) return {
393
+ success: true,
394
+ next: context,
395
+ consumed: []
396
+ };
390
397
  const nextState = injectAnnotations({
391
398
  [envBindStateKey]: true,
392
399
  hasCliValue: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/env",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Environment variable support for Optique",
5
5
  "keywords": [
6
6
  "CLI",
@@ -60,10 +60,10 @@
60
60
  },
61
61
  "sideEffects": false,
62
62
  "dependencies": {
63
- "@optique/core": "1.1.6"
63
+ "@optique/core": "1.1.7"
64
64
  },
65
65
  "devDependencies": {
66
- "@optique/config": "1.1.6",
66
+ "@optique/config": "1.1.7",
67
67
  "@types/node": "^24.0.0",
68
68
  "fast-check": "^4.7.0",
69
69
  "tsdown": "^0.13.0",