@karmaniverous/get-dotenv 4.2.4 → 4.3.1

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.mjs CHANGED
@@ -1,31 +1,30 @@
1
- import require$$0 from 'events';
2
- import require$$1 from 'child_process';
3
- import require$$0$1, { join } from 'path';
4
- import require$$0$2 from 'fs';
5
- import require$$4$1 from 'process';
1
+ import require$$0, { once, on, addAbortListener, setMaxListeners } from 'node:events';
2
+ import require$$1, { ChildProcess, spawnSync as spawnSync$1, spawn as spawn$1 } from 'node:child_process';
3
+ import path$s, { resolve, basename } from 'node:path';
4
+ import fs$v, { writeFileSync as writeFileSync$1, statSync as statSync$1, readFileSync as readFileSync$1, appendFileSync, createReadStream, createWriteStream } from 'node:fs';
5
+ import process$3, { hrtime, platform as platform$1, execPath, execArgv } from 'node:process';
6
6
  import { fileURLToPath } from 'node:url';
7
- import { ChildProcess, spawnSync as spawnSync$1, spawn as spawn$1 } from 'node:child_process';
8
7
  import { StringDecoder } from 'node:string_decoder';
9
8
  import tty from 'node:tty';
10
9
  import { debuglog, stripVTControlCharacters, callbackify, inspect, aborted } from 'node:util';
11
- import fs$v, { writeFileSync as writeFileSync$1, statSync as statSync$1, readFileSync as readFileSync$1, appendFileSync, createReadStream, createWriteStream } from 'node:fs';
12
- import process$3, { hrtime, platform as platform$1, execPath, execArgv } from 'node:process';
13
- import path$s, { resolve, basename } from 'node:path';
10
+ import require$$0$3 from 'child_process';
11
+ import require$$0$2, { join } from 'path';
12
+ import require$$0$1 from 'fs';
14
13
  import { setTimeout as setTimeout$1, setImmediate as setImmediate$1 } from 'node:timers/promises';
15
14
  import { constants as constants$6 } from 'node:os';
16
15
  import { Transform, getDefaultHighWaterMark, PassThrough as PassThrough$1, Readable, Writable, Duplex } from 'node:stream';
17
16
  import { Buffer as Buffer$1 } from 'node:buffer';
18
- import { once, on, addAbortListener, setMaxListeners } from 'node:events';
19
17
  import { finished } from 'node:stream/promises';
20
- import require$$0$3 from 'constants';
21
- import require$$0$4 from 'stream';
22
- import require$$0$5 from 'util';
18
+ import require$$0$4 from 'constants';
19
+ import require$$0$5 from 'stream';
20
+ import require$$0$6 from 'util';
23
21
  import require$$5 from 'assert';
24
22
  import { webcrypto } from 'node:crypto';
25
23
  import url, { fileURLToPath as fileURLToPath$1 } from 'url';
26
24
  import fsPromises from 'node:fs/promises';
27
25
  import require$$2 from 'os';
28
26
  import require$$3 from 'crypto';
27
+ import require$$0$7 from 'events';
29
28
 
30
29
  // like String.prototype.search but returns the last index
31
30
  const searchLast = (str, rgx) => {
@@ -120,7 +119,6 @@ var error$1 = {};
120
119
 
121
120
  /**
122
121
  * CommanderError class
123
- * @class
124
122
  */
125
123
 
126
124
  let CommanderError$3 = class CommanderError extends Error {
@@ -129,7 +127,6 @@ let CommanderError$3 = class CommanderError extends Error {
129
127
  * @param {number} exitCode suggested exit code which could be used with process.exit
130
128
  * @param {string} code an id string representing the error
131
129
  * @param {string} message human-readable description of the error
132
- * @constructor
133
130
  */
134
131
  constructor(exitCode, code, message) {
135
132
  super(message);
@@ -144,13 +141,11 @@ let CommanderError$3 = class CommanderError extends Error {
144
141
 
145
142
  /**
146
143
  * InvalidArgumentError class
147
- * @class
148
144
  */
149
145
  let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 {
150
146
  /**
151
147
  * Constructs the InvalidArgumentError class
152
148
  * @param {string} [message] explanation of why argument is invalid
153
- * @constructor
154
149
  */
155
150
  constructor(message) {
156
151
  super(1, 'commander.invalidArgument', message);
@@ -215,7 +210,7 @@ let Argument$3 = class Argument {
215
210
  }
216
211
 
217
212
  /**
218
- * @package internal use only
213
+ * @package
219
214
  */
220
215
 
221
216
  _concatValue(value, previous) {
@@ -263,7 +258,9 @@ let Argument$3 = class Argument {
263
258
  this.argChoices = values.slice();
264
259
  this.parseArg = (arg, previous) => {
265
260
  if (!this.argChoices.includes(arg)) {
266
- throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(', ')}.`);
261
+ throw new InvalidArgumentError$3(
262
+ `Allowed choices are ${this.argChoices.join(', ')}.`,
263
+ );
267
264
  }
268
265
  if (this.variadic) {
269
266
  return this._concatValue(arg, previous);
@@ -275,6 +272,8 @@ let Argument$3 = class Argument {
275
272
 
276
273
  /**
277
274
  * Make argument required.
275
+ *
276
+ * @returns {Argument}
278
277
  */
279
278
  argRequired() {
280
279
  this.required = true;
@@ -283,6 +282,8 @@ let Argument$3 = class Argument {
283
282
 
284
283
  /**
285
284
  * Make argument optional.
285
+ *
286
+ * @returns {Argument}
286
287
  */
287
288
  argOptional() {
288
289
  this.required = false;
@@ -301,9 +302,7 @@ let Argument$3 = class Argument {
301
302
  function humanReadableArgName$2(arg) {
302
303
  const nameOutput = arg.name() + (arg.variadic === true ? '...' : '');
303
304
 
304
- return arg.required
305
- ? '<' + nameOutput + '>'
306
- : '[' + nameOutput + ']';
305
+ return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
307
306
  }
308
307
 
309
308
  argument.Argument = Argument$3;
@@ -340,14 +339,14 @@ let Help$3 = class Help {
340
339
  */
341
340
 
342
341
  visibleCommands(cmd) {
343
- const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);
342
+ const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
344
343
  const helpCommand = cmd._getHelpCommand();
345
344
  if (helpCommand && !helpCommand._hidden) {
346
345
  visibleCommands.push(helpCommand);
347
346
  }
348
347
  if (this.sortSubcommands) {
349
348
  visibleCommands.sort((a, b) => {
350
- // @ts-ignore: overloaded return type
349
+ // @ts-ignore: because overloaded return type
351
350
  return a.name().localeCompare(b.name());
352
351
  });
353
352
  }
@@ -359,12 +358,14 @@ let Help$3 = class Help {
359
358
  *
360
359
  * @param {Option} a
361
360
  * @param {Option} b
362
- * @returns number
361
+ * @returns {number}
363
362
  */
364
363
  compareOptions(a, b) {
365
364
  const getSortKey = (option) => {
366
365
  // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
367
- return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
366
+ return option.short
367
+ ? option.short.replace(/^-/, '')
368
+ : option.long.replace(/^--/, '');
368
369
  };
369
370
  return getSortKey(a).localeCompare(getSortKey(b));
370
371
  }
@@ -387,9 +388,13 @@ let Help$3 = class Help {
387
388
  if (!removeShort && !removeLong) {
388
389
  visibleOptions.push(helpOption); // no changes needed
389
390
  } else if (helpOption.long && !removeLong) {
390
- visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
391
+ visibleOptions.push(
392
+ cmd.createOption(helpOption.long, helpOption.description),
393
+ );
391
394
  } else if (helpOption.short && !removeShort) {
392
- visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
395
+ visibleOptions.push(
396
+ cmd.createOption(helpOption.short, helpOption.description),
397
+ );
393
398
  }
394
399
  }
395
400
  if (this.sortOptions) {
@@ -409,8 +414,14 @@ let Help$3 = class Help {
409
414
  if (!this.showGlobalOptions) return [];
410
415
 
411
416
  const globalOptions = [];
412
- for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
413
- const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
417
+ for (
418
+ let ancestorCmd = cmd.parent;
419
+ ancestorCmd;
420
+ ancestorCmd = ancestorCmd.parent
421
+ ) {
422
+ const visibleOptions = ancestorCmd.options.filter(
423
+ (option) => !option.hidden,
424
+ );
414
425
  globalOptions.push(...visibleOptions);
415
426
  }
416
427
  if (this.sortOptions) {
@@ -429,13 +440,14 @@ let Help$3 = class Help {
429
440
  visibleArguments(cmd) {
430
441
  // Side effect! Apply the legacy descriptions before the arguments are displayed.
431
442
  if (cmd._argsDescription) {
432
- cmd.registeredArguments.forEach(argument => {
433
- argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
443
+ cmd.registeredArguments.forEach((argument) => {
444
+ argument.description =
445
+ argument.description || cmd._argsDescription[argument.name()] || '';
434
446
  });
435
447
  }
436
448
 
437
449
  // If there are any arguments with a description then return all the arguments.
438
- if (cmd.registeredArguments.find(argument => argument.description)) {
450
+ if (cmd.registeredArguments.find((argument) => argument.description)) {
439
451
  return cmd.registeredArguments;
440
452
  }
441
453
  return [];
@@ -450,11 +462,15 @@ let Help$3 = class Help {
450
462
 
451
463
  subcommandTerm(cmd) {
452
464
  // Legacy. Ignores custom usage string, and nested commands.
453
- const args = cmd.registeredArguments.map(arg => humanReadableArgName$1(arg)).join(' ');
454
- return cmd._name +
465
+ const args = cmd.registeredArguments
466
+ .map((arg) => humanReadableArgName$1(arg))
467
+ .join(' ');
468
+ return (
469
+ cmd._name +
455
470
  (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
456
471
  (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
457
- (args ? ' ' + args : '');
472
+ (args ? ' ' + args : '')
473
+ );
458
474
  }
459
475
 
460
476
  /**
@@ -549,7 +565,11 @@ let Help$3 = class Help {
549
565
  cmdName = cmdName + '|' + cmd._aliases[0];
550
566
  }
551
567
  let ancestorCmdNames = '';
552
- for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
568
+ for (
569
+ let ancestorCmd = cmd.parent;
570
+ ancestorCmd;
571
+ ancestorCmd = ancestorCmd.parent
572
+ ) {
553
573
  ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
554
574
  }
555
575
  return ancestorCmdNames + cmdName + ' ' + cmd.usage();
@@ -563,7 +583,7 @@ let Help$3 = class Help {
563
583
  */
564
584
 
565
585
  commandDescription(cmd) {
566
- // @ts-ignore: overloaded return type
586
+ // @ts-ignore: because overloaded return type
567
587
  return cmd.description();
568
588
  }
569
589
 
@@ -576,7 +596,7 @@ let Help$3 = class Help {
576
596
  */
577
597
 
578
598
  subcommandDescription(cmd) {
579
- // @ts-ignore: overloaded return type
599
+ // @ts-ignore: because overloaded return type
580
600
  return cmd.summary() || cmd.description();
581
601
  }
582
602
 
@@ -593,15 +613,20 @@ let Help$3 = class Help {
593
613
  if (option.argChoices) {
594
614
  extraInfo.push(
595
615
  // use stringify to match the display of the default value
596
- `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
616
+ `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
617
+ );
597
618
  }
598
619
  if (option.defaultValue !== undefined) {
599
620
  // default for boolean and negated more for programmer than end user,
600
621
  // but show true/false for boolean option as may be for hand-rolled env or config processing.
601
- const showDefault = option.required || option.optional ||
622
+ const showDefault =
623
+ option.required ||
624
+ option.optional ||
602
625
  (option.isBoolean() && typeof option.defaultValue === 'boolean');
603
626
  if (showDefault) {
604
- extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
627
+ extraInfo.push(
628
+ `default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,
629
+ );
605
630
  }
606
631
  }
607
632
  // preset for boolean and negated are more for programmer than end user
@@ -630,10 +655,13 @@ let Help$3 = class Help {
630
655
  if (argument.argChoices) {
631
656
  extraInfo.push(
632
657
  // use stringify to match the display of the default value
633
- `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
658
+ `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
659
+ );
634
660
  }
635
661
  if (argument.defaultValue !== undefined) {
636
- extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
662
+ extraInfo.push(
663
+ `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
664
+ );
637
665
  }
638
666
  if (extraInfo.length > 0) {
639
667
  const extraDescripton = `(${extraInfo.join(', ')})`;
@@ -661,7 +689,11 @@ let Help$3 = class Help {
661
689
  function formatItem(term, description) {
662
690
  if (description) {
663
691
  const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
664
- return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
692
+ return helper.wrap(
693
+ fullText,
694
+ helpWidth - itemIndentWidth,
695
+ termWidth + itemSeparatorWidth,
696
+ );
665
697
  }
666
698
  return term;
667
699
  }
@@ -675,12 +707,18 @@ let Help$3 = class Help {
675
707
  // Description
676
708
  const commandDescription = helper.commandDescription(cmd);
677
709
  if (commandDescription.length > 0) {
678
- output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']);
710
+ output = output.concat([
711
+ helper.wrap(commandDescription, helpWidth, 0),
712
+ '',
713
+ ]);
679
714
  }
680
715
 
681
716
  // Arguments
682
717
  const argumentList = helper.visibleArguments(cmd).map((argument) => {
683
- return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
718
+ return formatItem(
719
+ helper.argumentTerm(argument),
720
+ helper.argumentDescription(argument),
721
+ );
684
722
  });
685
723
  if (argumentList.length > 0) {
686
724
  output = output.concat(['Arguments:', formatList(argumentList), '']);
@@ -688,24 +726,39 @@ let Help$3 = class Help {
688
726
 
689
727
  // Options
690
728
  const optionList = helper.visibleOptions(cmd).map((option) => {
691
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
729
+ return formatItem(
730
+ helper.optionTerm(option),
731
+ helper.optionDescription(option),
732
+ );
692
733
  });
693
734
  if (optionList.length > 0) {
694
735
  output = output.concat(['Options:', formatList(optionList), '']);
695
736
  }
696
737
 
697
738
  if (this.showGlobalOptions) {
698
- const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
699
- return formatItem(helper.optionTerm(option), helper.optionDescription(option));
700
- });
739
+ const globalOptionList = helper
740
+ .visibleGlobalOptions(cmd)
741
+ .map((option) => {
742
+ return formatItem(
743
+ helper.optionTerm(option),
744
+ helper.optionDescription(option),
745
+ );
746
+ });
701
747
  if (globalOptionList.length > 0) {
702
- output = output.concat(['Global Options:', formatList(globalOptionList), '']);
748
+ output = output.concat([
749
+ 'Global Options:',
750
+ formatList(globalOptionList),
751
+ '',
752
+ ]);
703
753
  }
704
754
  }
705
755
 
706
756
  // Commands
707
757
  const commandList = helper.visibleCommands(cmd).map((cmd) => {
708
- return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
758
+ return formatItem(
759
+ helper.subcommandTerm(cmd),
760
+ helper.subcommandDescription(cmd),
761
+ );
709
762
  });
710
763
  if (commandList.length > 0) {
711
764
  output = output.concat(['Commands:', formatList(commandList), '']);
@@ -727,7 +780,7 @@ let Help$3 = class Help {
727
780
  helper.longestOptionTermLength(cmd, helper),
728
781
  helper.longestGlobalOptionTermLength(cmd, helper),
729
782
  helper.longestSubcommandTermLength(cmd, helper),
730
- helper.longestArgumentTermLength(cmd, helper)
783
+ helper.longestArgumentTermLength(cmd, helper),
731
784
  );
732
785
  }
733
786
 
@@ -745,7 +798,8 @@ let Help$3 = class Help {
745
798
 
746
799
  wrap(str, width, indent, minColumnWidth = 40) {
747
800
  // Full \s characters, minus the linefeeds.
748
- const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
801
+ const indents =
802
+ ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
749
803
  // Detect manually wrapped and indented strings by searching for line break followed by spaces.
750
804
  const manualIndent = new RegExp(`[\\n][${indents}]+`);
751
805
  if (str.match(manualIndent)) return str;
@@ -760,12 +814,20 @@ let Help$3 = class Help {
760
814
  const breaks = `\\s${zeroWidthSpace}`;
761
815
  // Match line end (so empty lines don't collapse),
762
816
  // or as much text as will fit in column, or excess text up to first break.
763
- const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g');
817
+ const regex = new RegExp(
818
+ `\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
819
+ 'g',
820
+ );
764
821
  const lines = columnText.match(regex) || [];
765
- return leadingStr + lines.map((line, i) => {
766
- if (line === '\n') return ''; // preserve empty lines
767
- return ((i > 0) ? indentString : '') + line.trimEnd();
768
- }).join('\n');
822
+ return (
823
+ leadingStr +
824
+ lines
825
+ .map((line, i) => {
826
+ if (line === '\n') return ''; // preserve empty lines
827
+ return (i > 0 ? indentString : '') + line.trimEnd();
828
+ })
829
+ .join('\n')
830
+ );
769
831
  }
770
832
  };
771
833
 
@@ -868,7 +930,7 @@ let Option$3 = class Option {
868
930
  * .addOption(new Option('--log', 'write logging information to file'))
869
931
  * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
870
932
  *
871
- * @param {Object} impliedOptionValues
933
+ * @param {object} impliedOptionValues
872
934
  * @return {Option}
873
935
  */
874
936
  implies(impliedOptionValues) {
@@ -933,7 +995,7 @@ let Option$3 = class Option {
933
995
  }
934
996
 
935
997
  /**
936
- * @package internal use only
998
+ * @package
937
999
  */
938
1000
 
939
1001
  _concatValue(value, previous) {
@@ -955,7 +1017,9 @@ let Option$3 = class Option {
955
1017
  this.argChoices = values.slice();
956
1018
  this.parseArg = (arg, previous) => {
957
1019
  if (!this.argChoices.includes(arg)) {
958
- throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(', ')}.`);
1020
+ throw new InvalidArgumentError$2(
1021
+ `Allowed choices are ${this.argChoices.join(', ')}.`,
1022
+ );
959
1023
  }
960
1024
  if (this.variadic) {
961
1025
  return this._concatValue(arg, previous);
@@ -994,7 +1058,7 @@ let Option$3 = class Option {
994
1058
  *
995
1059
  * @param {string} arg
996
1060
  * @return {boolean}
997
- * @package internal use only
1061
+ * @package
998
1062
  */
999
1063
 
1000
1064
  is(arg) {
@@ -1007,7 +1071,7 @@ let Option$3 = class Option {
1007
1071
  * Options are one of boolean, negated, required argument, or optional argument.
1008
1072
  *
1009
1073
  * @return {boolean}
1010
- * @package internal use only
1074
+ * @package
1011
1075
  */
1012
1076
 
1013
1077
  isBoolean() {
@@ -1030,7 +1094,7 @@ let DualOptions$1 = class DualOptions {
1030
1094
  this.positiveOptions = new Map();
1031
1095
  this.negativeOptions = new Map();
1032
1096
  this.dualOptions = new Set();
1033
- options.forEach(option => {
1097
+ options.forEach((option) => {
1034
1098
  if (option.negate) {
1035
1099
  this.negativeOptions.set(option.attributeName(), option);
1036
1100
  } else {
@@ -1057,7 +1121,7 @@ let DualOptions$1 = class DualOptions {
1057
1121
 
1058
1122
  // Use the value to deduce if (probably) came from the option.
1059
1123
  const preset = this.negativeOptions.get(optionKey).presetArg;
1060
- const negativeValue = (preset !== undefined) ? preset : false;
1124
+ const negativeValue = preset !== undefined ? preset : false;
1061
1125
  return option.negate === (negativeValue === value);
1062
1126
  }
1063
1127
  };
@@ -1088,7 +1152,8 @@ function splitOptionFlags(flags) {
1088
1152
  // Use original very loose parsing to maintain backwards compatibility for now,
1089
1153
  // which allowed for example unintended `-sw, --short-word` [sic].
1090
1154
  const flagParts = flags.split(/[ |,]+/);
1091
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
1155
+ if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
1156
+ shortFlag = flagParts.shift();
1092
1157
  longFlag = flagParts.shift();
1093
1158
  // Add support for lone short flag without significantly changing parsing!
1094
1159
  if (!shortFlag && /^-[^-]$/.test(longFlag)) {
@@ -1111,7 +1176,8 @@ function editDistance(a, b) {
1111
1176
  // (Simple implementation.)
1112
1177
 
1113
1178
  // Quick early exit, return worst case.
1114
- if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
1179
+ if (Math.abs(a.length - b.length) > maxDistance)
1180
+ return Math.max(a.length, b.length);
1115
1181
 
1116
1182
  // distance between prefix substrings of a and b
1117
1183
  const d = [];
@@ -1137,7 +1203,7 @@ function editDistance(a, b) {
1137
1203
  d[i][j] = Math.min(
1138
1204
  d[i - 1][j] + 1, // deletion
1139
1205
  d[i][j - 1] + 1, // insertion
1140
- d[i - 1][j - 1] + cost // substitution
1206
+ d[i - 1][j - 1] + cost, // substitution
1141
1207
  );
1142
1208
  // transposition
1143
1209
  if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
@@ -1165,7 +1231,7 @@ function suggestSimilar$1(word, candidates) {
1165
1231
  const searchingOptions = word.startsWith('--');
1166
1232
  if (searchingOptions) {
1167
1233
  word = word.slice(2);
1168
- candidates = candidates.map(candidate => candidate.slice(2));
1234
+ candidates = candidates.map((candidate) => candidate.slice(2));
1169
1235
  }
1170
1236
 
1171
1237
  let similar = [];
@@ -1190,7 +1256,7 @@ function suggestSimilar$1(word, candidates) {
1190
1256
 
1191
1257
  similar.sort((a, b) => a.localeCompare(b));
1192
1258
  if (searchingOptions) {
1193
- similar = similar.map(candidate => `--${candidate}`);
1259
+ similar = similar.map((candidate) => `--${candidate}`);
1194
1260
  }
1195
1261
 
1196
1262
  if (similar.length > 1) {
@@ -1206,9 +1272,9 @@ suggestSimilar$2.suggestSimilar = suggestSimilar$1;
1206
1272
 
1207
1273
  const EventEmitter = require$$0.EventEmitter;
1208
1274
  const childProcess = require$$1;
1209
- const path$r = require$$0$1;
1210
- const fs$u = require$$0$2;
1211
- const process$2 = require$$4$1;
1275
+ const path$r = path$s;
1276
+ const fs$u = fs$v;
1277
+ const process$2 = process$3;
1212
1278
 
1213
1279
  const { Argument: Argument$2, humanReadableArgName } = argument;
1214
1280
  const { CommanderError: CommanderError$2 } = error$1;
@@ -1266,9 +1332,11 @@ let Command$2 = class Command extends EventEmitter {
1266
1332
  this._outputConfiguration = {
1267
1333
  writeOut: (str) => process$2.stdout.write(str),
1268
1334
  writeErr: (str) => process$2.stderr.write(str),
1269
- getOutHelpWidth: () => process$2.stdout.isTTY ? process$2.stdout.columns : undefined,
1270
- getErrHelpWidth: () => process$2.stderr.isTTY ? process$2.stderr.columns : undefined,
1271
- outputError: (str, write) => write(str)
1335
+ getOutHelpWidth: () =>
1336
+ process$2.stdout.isTTY ? process$2.stdout.columns : undefined,
1337
+ getErrHelpWidth: () =>
1338
+ process$2.stderr.isTTY ? process$2.stderr.columns : undefined,
1339
+ outputError: (str, write) => write(str),
1272
1340
  };
1273
1341
 
1274
1342
  this._hidden = false;
@@ -1295,7 +1363,8 @@ let Command$2 = class Command extends EventEmitter {
1295
1363
  this._helpConfiguration = sourceCommand._helpConfiguration;
1296
1364
  this._exitCallback = sourceCommand._exitCallback;
1297
1365
  this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
1298
- this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
1366
+ this._combineFlagAndOptionalValue =
1367
+ sourceCommand._combineFlagAndOptionalValue;
1299
1368
  this._allowExcessArguments = sourceCommand._allowExcessArguments;
1300
1369
  this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
1301
1370
  this._showHelpAfterError = sourceCommand._showHelpAfterError;
@@ -1311,6 +1380,7 @@ let Command$2 = class Command extends EventEmitter {
1311
1380
 
1312
1381
  _getCommandAndAncestors() {
1313
1382
  const result = [];
1383
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1314
1384
  for (let command = this; command; command = command.parent) {
1315
1385
  result.push(command);
1316
1386
  }
@@ -1337,8 +1407,8 @@ let Command$2 = class Command extends EventEmitter {
1337
1407
  * .command('stop [service]', 'stop named service, or all if no name supplied');
1338
1408
  *
1339
1409
  * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
1340
- * @param {(Object|string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1341
- * @param {Object} [execOpts] - configuration options (for executable)
1410
+ * @param {(object | string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
1411
+ * @param {object} [execOpts] - configuration options (for executable)
1342
1412
  * @return {Command} returns new command for action handler, or `this` for executable command
1343
1413
  */
1344
1414
 
@@ -1398,8 +1468,8 @@ let Command$2 = class Command extends EventEmitter {
1398
1468
  * You can customise the help by overriding Help properties using configureHelp(),
1399
1469
  * or with a subclass of Help by overriding createHelp().
1400
1470
  *
1401
- * @param {Object} [configuration] - configuration options
1402
- * @return {(Command|Object)} `this` command for chaining, or stored configuration
1471
+ * @param {object} [configuration] - configuration options
1472
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1403
1473
  */
1404
1474
 
1405
1475
  configureHelp(configuration) {
@@ -1424,8 +1494,8 @@ let Command$2 = class Command extends EventEmitter {
1424
1494
  * // functions based on what is being written out
1425
1495
  * outputError(str, write) // used for displaying errors, and not used for displaying help
1426
1496
  *
1427
- * @param {Object} [configuration] - configuration options
1428
- * @return {(Command|Object)} `this` command for chaining, or stored configuration
1497
+ * @param {object} [configuration] - configuration options
1498
+ * @return {(Command | object)} `this` command for chaining, or stored configuration
1429
1499
  */
1430
1500
 
1431
1501
  configureOutput(configuration) {
@@ -1464,7 +1534,7 @@ let Command$2 = class Command extends EventEmitter {
1464
1534
  * See .command() for creating an attached subcommand which inherits settings from its parent.
1465
1535
  *
1466
1536
  * @param {Command} cmd - new subcommand
1467
- * @param {Object} [opts] - configuration options
1537
+ * @param {object} [opts] - configuration options
1468
1538
  * @return {Command} `this` command for chaining
1469
1539
  */
1470
1540
 
@@ -1540,9 +1610,12 @@ let Command$2 = class Command extends EventEmitter {
1540
1610
  */
1541
1611
 
1542
1612
  arguments(names) {
1543
- names.trim().split(/ +/).forEach((detail) => {
1544
- this.argument(detail);
1545
- });
1613
+ names
1614
+ .trim()
1615
+ .split(/ +/)
1616
+ .forEach((detail) => {
1617
+ this.argument(detail);
1618
+ });
1546
1619
  return this;
1547
1620
  }
1548
1621
 
@@ -1555,10 +1628,18 @@ let Command$2 = class Command extends EventEmitter {
1555
1628
  addArgument(argument) {
1556
1629
  const previousArgument = this.registeredArguments.slice(-1)[0];
1557
1630
  if (previousArgument && previousArgument.variadic) {
1558
- throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
1631
+ throw new Error(
1632
+ `only the last argument can be variadic '${previousArgument.name()}'`,
1633
+ );
1559
1634
  }
1560
- if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) {
1561
- throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
1635
+ if (
1636
+ argument.required &&
1637
+ argument.defaultValue !== undefined &&
1638
+ argument.parseArg === undefined
1639
+ ) {
1640
+ throw new Error(
1641
+ `a default value for a required argument is never used: '${argument.name()}'`,
1642
+ );
1562
1643
  }
1563
1644
  this.registeredArguments.push(argument);
1564
1645
  return this;
@@ -1567,6 +1648,7 @@ let Command$2 = class Command extends EventEmitter {
1567
1648
  /**
1568
1649
  * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
1569
1650
  *
1651
+ * @example
1570
1652
  * program.helpCommand('help [cmd]');
1571
1653
  * program.helpCommand('help [cmd]', 'show help');
1572
1654
  * program.helpCommand(false); // suppress default help command
@@ -1625,8 +1707,11 @@ let Command$2 = class Command extends EventEmitter {
1625
1707
  * @package
1626
1708
  */
1627
1709
  _getHelpCommand() {
1628
- const hasImplicitHelpCommand = this._addImplicitHelpCommand ??
1629
- (this.commands.length && !this._actionHandler && !this._findCommand('help'));
1710
+ const hasImplicitHelpCommand =
1711
+ this._addImplicitHelpCommand ??
1712
+ (this.commands.length &&
1713
+ !this._actionHandler &&
1714
+ !this._findCommand('help'));
1630
1715
 
1631
1716
  if (hasImplicitHelpCommand) {
1632
1717
  if (this._helpCommand === undefined) {
@@ -1772,14 +1857,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
1772
1857
  * Register option if no conflicts found, or throw on conflict.
1773
1858
  *
1774
1859
  * @param {Option} option
1775
- * @api private
1860
+ * @private
1776
1861
  */
1777
1862
 
1778
1863
  _registerOption(option) {
1779
- const matchingOption = (option.short && this._findOption(option.short)) ||
1864
+ const matchingOption =
1865
+ (option.short && this._findOption(option.short)) ||
1780
1866
  (option.long && this._findOption(option.long));
1781
1867
  if (matchingOption) {
1782
- const matchingFlag = (option.long && this._findOption(option.long)) ? option.long : option.short;
1868
+ const matchingFlag =
1869
+ option.long && this._findOption(option.long)
1870
+ ? option.long
1871
+ : option.short;
1783
1872
  throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}'
1784
1873
  - already used by option '${matchingOption.flags}'`);
1785
1874
  }
@@ -1792,7 +1881,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1792
1881
  * Register command if no conflicts found, or throw on conflict.
1793
1882
  *
1794
1883
  * @param {Command} command
1795
- * @api private
1884
+ * @private
1796
1885
  */
1797
1886
 
1798
1887
  _registerCommand(command) {
@@ -1800,11 +1889,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
1800
1889
  return [cmd.name()].concat(cmd.aliases());
1801
1890
  };
1802
1891
 
1803
- const alreadyUsed = knownBy(command).find((name) => this._findCommand(name));
1892
+ const alreadyUsed = knownBy(command).find((name) =>
1893
+ this._findCommand(name),
1894
+ );
1804
1895
  if (alreadyUsed) {
1805
1896
  const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|');
1806
1897
  const newCmd = knownBy(command).join('|');
1807
- throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`);
1898
+ throw new Error(
1899
+ `cannot add command '${newCmd}' as already have command '${existingCmd}'`,
1900
+ );
1808
1901
  }
1809
1902
 
1810
1903
  this.commands.push(command);
@@ -1827,7 +1920,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1827
1920
  // --no-foo is special and defaults foo to true, unless a --foo option is already defined
1828
1921
  const positiveLongFlag = option.long.replace(/^--no-/, '--');
1829
1922
  if (!this._findOption(positiveLongFlag)) {
1830
- this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, 'default');
1923
+ this.setOptionValueWithSource(
1924
+ name,
1925
+ option.defaultValue === undefined ? true : option.defaultValue,
1926
+ 'default',
1927
+ );
1831
1928
  }
1832
1929
  } else if (option.defaultValue !== undefined) {
1833
1930
  this.setOptionValueWithSource(name, option.defaultValue, 'default');
@@ -1880,11 +1977,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
1880
1977
  /**
1881
1978
  * Internal implementation shared by .option() and .requiredOption()
1882
1979
  *
1980
+ * @return {Command} `this` command for chaining
1883
1981
  * @private
1884
1982
  */
1885
1983
  _optionEx(config, flags, description, fn, defaultValue) {
1886
1984
  if (typeof flags === 'object' && flags instanceof Option$2) {
1887
- throw new Error('To add an Option object use addOption() instead of option() or requiredOption()');
1985
+ throw new Error(
1986
+ 'To add an Option object use addOption() instead of option() or requiredOption()',
1987
+ );
1888
1988
  }
1889
1989
  const option = this.createOption(flags, description);
1890
1990
  option.makeOptionMandatory(!!config.mandatory);
@@ -1932,20 +2032,26 @@ Expecting one of '${allowedValues.join("', '")}'`);
1932
2032
  }
1933
2033
 
1934
2034
  /**
1935
- * Add a required option which must have a value after parsing. This usually means
1936
- * the option must be specified on the command line. (Otherwise the same as .option().)
1937
- *
1938
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
1939
- *
1940
- * @param {string} flags
1941
- * @param {string} [description]
1942
- * @param {(Function|*)} [parseArg] - custom option processing function or default value
1943
- * @param {*} [defaultValue]
1944
- * @return {Command} `this` command for chaining
1945
- */
2035
+ * Add a required option which must have a value after parsing. This usually means
2036
+ * the option must be specified on the command line. (Otherwise the same as .option().)
2037
+ *
2038
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
2039
+ *
2040
+ * @param {string} flags
2041
+ * @param {string} [description]
2042
+ * @param {(Function|*)} [parseArg] - custom option processing function or default value
2043
+ * @param {*} [defaultValue]
2044
+ * @return {Command} `this` command for chaining
2045
+ */
1946
2046
 
1947
2047
  requiredOption(flags, description, parseArg, defaultValue) {
1948
- return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue);
2048
+ return this._optionEx(
2049
+ { mandatory: true },
2050
+ flags,
2051
+ description,
2052
+ parseArg,
2053
+ defaultValue,
2054
+ );
1949
2055
  }
1950
2056
 
1951
2057
  /**
@@ -1956,7 +2062,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1956
2062
  * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
1957
2063
  * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
1958
2064
  *
1959
- * @param {boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
2065
+ * @param {boolean} [combine] - if `true` or omitted, an optional value can be specified directly after the flag.
2066
+ * @return {Command} `this` command for chaining
1960
2067
  */
1961
2068
  combineFlagAndOptionalValue(combine = true) {
1962
2069
  this._combineFlagAndOptionalValue = !!combine;
@@ -1966,8 +2073,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1966
2073
  /**
1967
2074
  * Allow unknown options on the command line.
1968
2075
  *
1969
- * @param {boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
1970
- * for unknown options.
2076
+ * @param {boolean} [allowUnknown] - if `true` or omitted, no error will be thrown for unknown options.
2077
+ * @return {Command} `this` command for chaining
1971
2078
  */
1972
2079
  allowUnknownOption(allowUnknown = true) {
1973
2080
  this._allowUnknownOption = !!allowUnknown;
@@ -1977,8 +2084,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1977
2084
  /**
1978
2085
  * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
1979
2086
  *
1980
- * @param {boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
1981
- * for excess arguments.
2087
+ * @param {boolean} [allowExcess] - if `true` or omitted, no error will be thrown for excess arguments.
2088
+ * @return {Command} `this` command for chaining
1982
2089
  */
1983
2090
  allowExcessArguments(allowExcess = true) {
1984
2091
  this._allowExcessArguments = !!allowExcess;
@@ -1990,7 +2097,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1990
2097
  * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
1991
2098
  * The default behaviour is non-positional and global options may appear anywhere on the command line.
1992
2099
  *
1993
- * @param {boolean} [positional=true]
2100
+ * @param {boolean} [positional]
2101
+ * @return {Command} `this` command for chaining
1994
2102
  */
1995
2103
  enablePositionalOptions(positional = true) {
1996
2104
  this._enablePositionalOptions = !!positional;
@@ -2003,8 +2111,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2003
2111
  * positional options to have been enabled on the program (parent commands).
2004
2112
  * The default behaviour is non-positional and options may appear before or after command-arguments.
2005
2113
  *
2006
- * @param {boolean} [passThrough=true]
2007
- * for unknown options.
2114
+ * @param {boolean} [passThrough] for unknown options.
2115
+ * @return {Command} `this` command for chaining
2008
2116
  */
2009
2117
  passThroughOptions(passThrough = true) {
2010
2118
  this._passThroughOptions = !!passThrough;
@@ -2017,25 +2125,33 @@ Expecting one of '${allowedValues.join("', '")}'`);
2017
2125
  */
2018
2126
 
2019
2127
  _checkForBrokenPassThrough() {
2020
- if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) {
2021
- throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`);
2128
+ if (
2129
+ this.parent &&
2130
+ this._passThroughOptions &&
2131
+ !this.parent._enablePositionalOptions
2132
+ ) {
2133
+ throw new Error(
2134
+ `passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`,
2135
+ );
2022
2136
  }
2023
2137
  }
2024
2138
 
2025
2139
  /**
2026
- * Whether to store option values as properties on command object,
2027
- * or store separately (specify false). In both cases the option values can be accessed using .opts().
2028
- *
2029
- * @param {boolean} [storeAsProperties=true]
2030
- * @return {Command} `this` command for chaining
2031
- */
2140
+ * Whether to store option values as properties on command object,
2141
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
2142
+ *
2143
+ * @param {boolean} [storeAsProperties=true]
2144
+ * @return {Command} `this` command for chaining
2145
+ */
2032
2146
 
2033
2147
  storeOptionsAsProperties(storeAsProperties = true) {
2034
2148
  if (this.options.length) {
2035
2149
  throw new Error('call .storeOptionsAsProperties() before adding options');
2036
2150
  }
2037
2151
  if (Object.keys(this._optionValues).length) {
2038
- throw new Error('call .storeOptionsAsProperties() before setting option values');
2152
+ throw new Error(
2153
+ 'call .storeOptionsAsProperties() before setting option values',
2154
+ );
2039
2155
  }
2040
2156
  this._storeOptionsAsProperties = !!storeAsProperties;
2041
2157
  return this;
@@ -2045,7 +2161,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2045
2161
  * Retrieve option value.
2046
2162
  *
2047
2163
  * @param {string} key
2048
- * @return {Object} value
2164
+ * @return {object} value
2049
2165
  */
2050
2166
 
2051
2167
  getOptionValue(key) {
@@ -2059,7 +2175,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2059
2175
  * Store option value.
2060
2176
  *
2061
2177
  * @param {string} key
2062
- * @param {Object} value
2178
+ * @param {object} value
2063
2179
  * @return {Command} `this` command for chaining
2064
2180
  */
2065
2181
 
@@ -2068,13 +2184,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2068
2184
  }
2069
2185
 
2070
2186
  /**
2071
- * Store option value and where the value came from.
2072
- *
2073
- * @param {string} key
2074
- * @param {Object} value
2075
- * @param {string} source - expected values are default/config/env/cli/implied
2076
- * @return {Command} `this` command for chaining
2077
- */
2187
+ * Store option value and where the value came from.
2188
+ *
2189
+ * @param {string} key
2190
+ * @param {object} value
2191
+ * @param {string} source - expected values are default/config/env/cli/implied
2192
+ * @return {Command} `this` command for chaining
2193
+ */
2078
2194
 
2079
2195
  setOptionValueWithSource(key, value, source) {
2080
2196
  if (this._storeOptionsAsProperties) {
@@ -2087,24 +2203,24 @@ Expecting one of '${allowedValues.join("', '")}'`);
2087
2203
  }
2088
2204
 
2089
2205
  /**
2090
- * Get source of option value.
2091
- * Expected values are default | config | env | cli | implied
2092
- *
2093
- * @param {string} key
2094
- * @return {string}
2095
- */
2206
+ * Get source of option value.
2207
+ * Expected values are default | config | env | cli | implied
2208
+ *
2209
+ * @param {string} key
2210
+ * @return {string}
2211
+ */
2096
2212
 
2097
2213
  getOptionValueSource(key) {
2098
2214
  return this._optionValueSources[key];
2099
2215
  }
2100
2216
 
2101
2217
  /**
2102
- * Get source of option value. See also .optsWithGlobals().
2103
- * Expected values are default | config | env | cli | implied
2104
- *
2105
- * @param {string} key
2106
- * @return {string}
2107
- */
2218
+ * Get source of option value. See also .optsWithGlobals().
2219
+ * Expected values are default | config | env | cli | implied
2220
+ *
2221
+ * @param {string} key
2222
+ * @return {string}
2223
+ */
2108
2224
 
2109
2225
  getOptionValueSourceWithGlobals(key) {
2110
2226
  // global overwrites local, like optsWithGlobals
@@ -2130,17 +2246,30 @@ Expecting one of '${allowedValues.join("', '")}'`);
2130
2246
  }
2131
2247
  parseOptions = parseOptions || {};
2132
2248
 
2133
- // Default to using process.argv
2134
- if (argv === undefined) {
2135
- argv = process$2.argv;
2136
- // @ts-ignore: unknown property
2137
- if (process$2.versions && process$2.versions.electron) {
2249
+ // auto-detect argument conventions if nothing supplied
2250
+ if (argv === undefined && parseOptions.from === undefined) {
2251
+ if (process$2.versions?.electron) {
2138
2252
  parseOptions.from = 'electron';
2139
2253
  }
2254
+ // check node specific options for scenarios where user CLI args follow executable without scriptname
2255
+ const execArgv = process$2.execArgv ?? [];
2256
+ if (
2257
+ execArgv.includes('-e') ||
2258
+ execArgv.includes('--eval') ||
2259
+ execArgv.includes('-p') ||
2260
+ execArgv.includes('--print')
2261
+ ) {
2262
+ parseOptions.from = 'eval'; // internal usage, not documented
2263
+ }
2264
+ }
2265
+
2266
+ // default to using process.argv
2267
+ if (argv === undefined) {
2268
+ argv = process$2.argv;
2140
2269
  }
2141
2270
  this.rawArgs = argv.slice();
2142
2271
 
2143
- // make it a little easier for callers by supporting various argv conventions
2272
+ // extract the user args and scriptPath
2144
2273
  let userArgs;
2145
2274
  switch (parseOptions.from) {
2146
2275
  case undefined:
@@ -2149,7 +2278,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2149
2278
  userArgs = argv.slice(2);
2150
2279
  break;
2151
2280
  case 'electron':
2152
- // @ts-ignore: unknown property
2281
+ // @ts-ignore: because defaultApp is an unknown property
2153
2282
  if (process$2.defaultApp) {
2154
2283
  this._scriptPath = argv[1];
2155
2284
  userArgs = argv.slice(2);
@@ -2160,12 +2289,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2160
2289
  case 'user':
2161
2290
  userArgs = argv.slice(0);
2162
2291
  break;
2292
+ case 'eval':
2293
+ userArgs = argv.slice(1);
2294
+ break;
2163
2295
  default:
2164
- throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
2296
+ throw new Error(
2297
+ `unexpected parse option { from: '${parseOptions.from}' }`,
2298
+ );
2165
2299
  }
2166
2300
 
2167
2301
  // Find default name for program from arguments.
2168
- if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath);
2302
+ if (!this._name && this._scriptPath)
2303
+ this.nameFromFilename(this._scriptPath);
2169
2304
  this._name = this._name || 'program';
2170
2305
 
2171
2306
  return userArgs;
@@ -2174,16 +2309,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
2174
2309
  /**
2175
2310
  * Parse `argv`, setting options and invoking commands when defined.
2176
2311
  *
2177
- * The default expectation is that the arguments are from node and have the application as argv[0]
2178
- * and the script being run in argv[1], with user parameters after that.
2312
+ * Use parseAsync instead of parse if any of your action handlers are async.
2313
+ *
2314
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
2315
+ *
2316
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
2317
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
2318
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
2319
+ * - `'user'`: just user arguments
2179
2320
  *
2180
2321
  * @example
2181
- * program.parse(process.argv);
2182
- * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
2322
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
2323
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
2183
2324
  * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
2184
2325
  *
2185
2326
  * @param {string[]} [argv] - optional, defaults to process.argv
2186
- * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
2327
+ * @param {object} [parseOptions] - optionally specify style of options with from: node/user/electron
2187
2328
  * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
2188
2329
  * @return {Command} `this` command for chaining
2189
2330
  */
@@ -2198,18 +2339,20 @@ Expecting one of '${allowedValues.join("', '")}'`);
2198
2339
  /**
2199
2340
  * Parse `argv`, setting options and invoking commands when defined.
2200
2341
  *
2201
- * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
2342
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
2202
2343
  *
2203
- * The default expectation is that the arguments are from node and have the application as argv[0]
2204
- * and the script being run in argv[1], with user parameters after that.
2344
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
2345
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
2346
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
2347
+ * - `'user'`: just user arguments
2205
2348
  *
2206
2349
  * @example
2207
- * await program.parseAsync(process.argv);
2208
- * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
2350
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
2351
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
2209
2352
  * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
2210
2353
  *
2211
2354
  * @param {string[]} [argv]
2212
- * @param {Object} [parseOptions]
2355
+ * @param {object} [parseOptions]
2213
2356
  * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
2214
2357
  * @return {Promise}
2215
2358
  */
@@ -2241,7 +2384,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2241
2384
  if (sourceExt.includes(path$r.extname(baseName))) return undefined;
2242
2385
 
2243
2386
  // Try all the extensions.
2244
- const foundExt = sourceExt.find(ext => fs$u.existsSync(`${localBin}${ext}`));
2387
+ const foundExt = sourceExt.find((ext) =>
2388
+ fs$u.existsSync(`${localBin}${ext}`),
2389
+ );
2245
2390
  if (foundExt) return `${localBin}${foundExt}`;
2246
2391
 
2247
2392
  return undefined;
@@ -2252,7 +2397,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2252
2397
  this._checkForConflictingOptions();
2253
2398
 
2254
2399
  // executableFile and executableDir might be full path, or just a name
2255
- let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
2400
+ let executableFile =
2401
+ subcommand._executableFile || `${this._name}-${subcommand._name}`;
2256
2402
  let executableDir = this._executableDir || '';
2257
2403
  if (this._scriptPath) {
2258
2404
  let resolvedScriptPath; // resolve possible symlink for installed npm binary
@@ -2261,7 +2407,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2261
2407
  } catch (err) {
2262
2408
  resolvedScriptPath = this._scriptPath;
2263
2409
  }
2264
- executableDir = path$r.resolve(path$r.dirname(resolvedScriptPath), executableDir);
2410
+ executableDir = path$r.resolve(
2411
+ path$r.dirname(resolvedScriptPath),
2412
+ executableDir,
2413
+ );
2265
2414
  }
2266
2415
 
2267
2416
  // Look for a local file in preference to a command in PATH.
@@ -2270,9 +2419,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
2270
2419
 
2271
2420
  // Legacy search using prefix of script name instead of command name
2272
2421
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2273
- const legacyName = path$r.basename(this._scriptPath, path$r.extname(this._scriptPath));
2422
+ const legacyName = path$r.basename(
2423
+ this._scriptPath,
2424
+ path$r.extname(this._scriptPath),
2425
+ );
2274
2426
  if (legacyName !== this._name) {
2275
- localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
2427
+ localFile = findFile(
2428
+ executableDir,
2429
+ `${legacyName}-${subcommand._name}`,
2430
+ );
2276
2431
  }
2277
2432
  }
2278
2433
  executableFile = localFile || executableFile;
@@ -2298,12 +2453,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2298
2453
  proc = childProcess.spawn(process$2.execPath, args, { stdio: 'inherit' });
2299
2454
  }
2300
2455
 
2301
- if (!proc.killed) { // testing mainly to avoid leak warnings during unit tests with mocked spawn
2456
+ if (!proc.killed) {
2457
+ // testing mainly to avoid leak warnings during unit tests with mocked spawn
2302
2458
  const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
2303
2459
  signals.forEach((signal) => {
2304
- // @ts-ignore
2305
2460
  process$2.on(signal, () => {
2306
2461
  if (proc.killed === false && proc.exitCode === null) {
2462
+ // @ts-ignore because signals not typed to known strings
2307
2463
  proc.kill(signal);
2308
2464
  }
2309
2465
  });
@@ -2312,16 +2468,22 @@ Expecting one of '${allowedValues.join("', '")}'`);
2312
2468
 
2313
2469
  // By default terminate process when spawned process terminates.
2314
2470
  const exitCallback = this._exitCallback;
2315
- proc.on('close', (code, _signal) => {
2471
+ proc.on('close', (code) => {
2316
2472
  code = code ?? 1; // code is null if spawned process terminated due to a signal
2317
2473
  if (!exitCallback) {
2318
2474
  process$2.exit(code);
2319
2475
  } else {
2320
- exitCallback(new CommanderError$2(code, 'commander.executeSubCommandAsync', '(close)'));
2476
+ exitCallback(
2477
+ new CommanderError$2(
2478
+ code,
2479
+ 'commander.executeSubCommandAsync',
2480
+ '(close)',
2481
+ ),
2482
+ );
2321
2483
  }
2322
2484
  });
2323
2485
  proc.on('error', (err) => {
2324
- // @ts-ignore
2486
+ // @ts-ignore: because err.code is an unknown property
2325
2487
  if (err.code === 'ENOENT') {
2326
2488
  const executableDirMessage = executableDir
2327
2489
  ? `searched for local subcommand relative to directory '${executableDir}'`
@@ -2331,14 +2493,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2331
2493
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
2332
2494
  - ${executableDirMessage}`;
2333
2495
  throw new Error(executableMissing);
2334
- // @ts-ignore
2496
+ // @ts-ignore: because err.code is an unknown property
2335
2497
  } else if (err.code === 'EACCES') {
2336
2498
  throw new Error(`'${executableFile}' not executable`);
2337
2499
  }
2338
2500
  if (!exitCallback) {
2339
2501
  process$2.exit(1);
2340
2502
  } else {
2341
- const wrappedError = new CommanderError$2(1, 'commander.executeSubCommandAsync', '(error)');
2503
+ const wrappedError = new CommanderError$2(
2504
+ 1,
2505
+ 'commander.executeSubCommandAsync',
2506
+ '(error)',
2507
+ );
2342
2508
  wrappedError.nestedError = err;
2343
2509
  exitCallback(wrappedError);
2344
2510
  }
@@ -2357,7 +2523,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2357
2523
  if (!subCommand) this.help({ error: true });
2358
2524
 
2359
2525
  let promiseChain;
2360
- promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, 'preSubcommand');
2526
+ promiseChain = this._chainOrCallSubCommandHook(
2527
+ promiseChain,
2528
+ subCommand,
2529
+ 'preSubcommand',
2530
+ );
2361
2531
  promiseChain = this._chainOrCall(promiseChain, () => {
2362
2532
  if (subCommand._executableHandler) {
2363
2533
  this._executeSubCommand(subCommand, operands.concat(unknown));
@@ -2385,9 +2555,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2385
2555
  }
2386
2556
 
2387
2557
  // Fallback to parsing the help flag to invoke the help.
2388
- return this._dispatchSubcommand(subcommandName, [], [
2389
- this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'
2390
- ]);
2558
+ return this._dispatchSubcommand(
2559
+ subcommandName,
2560
+ [],
2561
+ [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help'],
2562
+ );
2391
2563
  }
2392
2564
 
2393
2565
  /**
@@ -2404,7 +2576,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2404
2576
  }
2405
2577
  });
2406
2578
  // too many
2407
- if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) {
2579
+ if (
2580
+ this.registeredArguments.length > 0 &&
2581
+ this.registeredArguments[this.registeredArguments.length - 1].variadic
2582
+ ) {
2408
2583
  return;
2409
2584
  }
2410
2585
  if (this.args.length > this.registeredArguments.length) {
@@ -2424,7 +2599,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
2424
2599
  let parsedValue = value;
2425
2600
  if (value !== null && argument.parseArg) {
2426
2601
  const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`;
2427
- parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage);
2602
+ parsedValue = this._callParseArg(
2603
+ argument,
2604
+ value,
2605
+ previous,
2606
+ invalidValueMessage,
2607
+ );
2428
2608
  }
2429
2609
  return parsedValue;
2430
2610
  };
@@ -2489,8 +2669,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2489
2669
  const hooks = [];
2490
2670
  this._getCommandAndAncestors()
2491
2671
  .reverse()
2492
- .filter(cmd => cmd._lifeCycleHooks[event] !== undefined)
2493
- .forEach(hookedCommand => {
2672
+ .filter((cmd) => cmd._lifeCycleHooks[event] !== undefined)
2673
+ .forEach((hookedCommand) => {
2494
2674
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
2495
2675
  hooks.push({ hookedCommand, callback });
2496
2676
  });
@@ -2546,14 +2726,26 @@ Expecting one of '${allowedValues.join("', '")}'`);
2546
2726
  if (operands && this._findCommand(operands[0])) {
2547
2727
  return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
2548
2728
  }
2549
- if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {
2729
+ if (
2730
+ this._getHelpCommand() &&
2731
+ operands[0] === this._getHelpCommand().name()
2732
+ ) {
2550
2733
  return this._dispatchHelpCommand(operands[1]);
2551
2734
  }
2552
2735
  if (this._defaultCommandName) {
2553
2736
  this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command
2554
- return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
2737
+ return this._dispatchSubcommand(
2738
+ this._defaultCommandName,
2739
+ operands,
2740
+ unknown,
2741
+ );
2555
2742
  }
2556
- if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
2743
+ if (
2744
+ this.commands.length &&
2745
+ this.args.length === 0 &&
2746
+ !this._actionHandler &&
2747
+ !this._defaultCommandName
2748
+ ) {
2557
2749
  // probably missing subcommand and no handler, user needs help (and exit)
2558
2750
  this.help({ error: true });
2559
2751
  }
@@ -2576,7 +2768,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2576
2768
 
2577
2769
  let promiseChain;
2578
2770
  promiseChain = this._chainOrCallHooks(promiseChain, 'preAction');
2579
- promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs));
2771
+ promiseChain = this._chainOrCall(promiseChain, () =>
2772
+ this._actionHandler(this.processedArgs),
2773
+ );
2580
2774
  if (this.parent) {
2581
2775
  promiseChain = this._chainOrCall(promiseChain, () => {
2582
2776
  this.parent.emit(commandEvent, operands, unknown); // legacy
@@ -2590,7 +2784,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2590
2784
  this._processArguments();
2591
2785
  this.parent.emit(commandEvent, operands, unknown); // legacy
2592
2786
  } else if (operands.length) {
2593
- if (this._findCommand('*')) { // legacy default command
2787
+ if (this._findCommand('*')) {
2788
+ // legacy default command
2594
2789
  return this._dispatchSubcommand('*', operands, unknown);
2595
2790
  }
2596
2791
  if (this.listenerCount('command:*')) {
@@ -2617,10 +2812,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2617
2812
  * Find matching command.
2618
2813
  *
2619
2814
  * @private
2815
+ * @return {Command | undefined}
2620
2816
  */
2621
2817
  _findCommand(name) {
2622
2818
  if (!name) return undefined;
2623
- return this.commands.find(cmd => cmd._name === name || cmd._aliases.includes(name));
2819
+ return this.commands.find(
2820
+ (cmd) => cmd._name === name || cmd._aliases.includes(name),
2821
+ );
2624
2822
  }
2625
2823
 
2626
2824
  /**
@@ -2628,11 +2826,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2628
2826
  *
2629
2827
  * @param {string} arg
2630
2828
  * @return {Option}
2631
- * @package internal use only
2829
+ * @package
2632
2830
  */
2633
2831
 
2634
2832
  _findOption(arg) {
2635
- return this.options.find(option => option.is(arg));
2833
+ return this.options.find((option) => option.is(arg));
2636
2834
  }
2637
2835
 
2638
2836
  /**
@@ -2646,7 +2844,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2646
2844
  // Walk up hierarchy so can call in subcommand after checking for displaying help.
2647
2845
  this._getCommandAndAncestors().forEach((cmd) => {
2648
2846
  cmd.options.forEach((anOption) => {
2649
- if (anOption.mandatory && (cmd.getOptionValue(anOption.attributeName()) === undefined)) {
2847
+ if (
2848
+ anOption.mandatory &&
2849
+ cmd.getOptionValue(anOption.attributeName()) === undefined
2850
+ ) {
2650
2851
  cmd.missingMandatoryOptionValue(anOption);
2651
2852
  }
2652
2853
  });
@@ -2659,23 +2860,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
2659
2860
  * @private
2660
2861
  */
2661
2862
  _checkForConflictingLocalOptions() {
2662
- const definedNonDefaultOptions = this.options.filter(
2663
- (option) => {
2664
- const optionKey = option.attributeName();
2665
- if (this.getOptionValue(optionKey) === undefined) {
2666
- return false;
2667
- }
2668
- return this.getOptionValueSource(optionKey) !== 'default';
2863
+ const definedNonDefaultOptions = this.options.filter((option) => {
2864
+ const optionKey = option.attributeName();
2865
+ if (this.getOptionValue(optionKey) === undefined) {
2866
+ return false;
2669
2867
  }
2670
- );
2868
+ return this.getOptionValueSource(optionKey) !== 'default';
2869
+ });
2671
2870
 
2672
2871
  const optionsWithConflicting = definedNonDefaultOptions.filter(
2673
- (option) => option.conflictsWith.length > 0
2872
+ (option) => option.conflictsWith.length > 0,
2674
2873
  );
2675
2874
 
2676
2875
  optionsWithConflicting.forEach((option) => {
2677
2876
  const conflictingAndDefined = definedNonDefaultOptions.find((defined) =>
2678
- option.conflictsWith.includes(defined.attributeName())
2877
+ option.conflictsWith.includes(defined.attributeName()),
2679
2878
  );
2680
2879
  if (conflictingAndDefined) {
2681
2880
  this._conflictingOption(option, conflictingAndDefined);
@@ -2755,7 +2954,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2755
2954
  value = args.shift();
2756
2955
  }
2757
2956
  this.emit(`option:${option.name()}`, value);
2758
- } else { // boolean flag
2957
+ } else {
2958
+ // boolean flag
2759
2959
  this.emit(`option:${option.name()}`);
2760
2960
  }
2761
2961
  activeVariadicOption = option.variadic ? option : null;
@@ -2767,7 +2967,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2767
2967
  if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') {
2768
2968
  const option = this._findOption(`-${arg[1]}`);
2769
2969
  if (option) {
2770
- if (option.required || (option.optional && this._combineFlagAndOptionalValue)) {
2970
+ if (
2971
+ option.required ||
2972
+ (option.optional && this._combineFlagAndOptionalValue)
2973
+ ) {
2771
2974
  // option with value following in same argument
2772
2975
  this.emit(`option:${option.name()}`, arg.slice(2));
2773
2976
  } else {
@@ -2798,12 +3001,19 @@ Expecting one of '${allowedValues.join("', '")}'`);
2798
3001
  }
2799
3002
 
2800
3003
  // If using positionalOptions, stop processing our options at subcommand.
2801
- if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
3004
+ if (
3005
+ (this._enablePositionalOptions || this._passThroughOptions) &&
3006
+ operands.length === 0 &&
3007
+ unknown.length === 0
3008
+ ) {
2802
3009
  if (this._findCommand(arg)) {
2803
3010
  operands.push(arg);
2804
3011
  if (args.length > 0) unknown.push(...args);
2805
3012
  break;
2806
- } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {
3013
+ } else if (
3014
+ this._getHelpCommand() &&
3015
+ arg === this._getHelpCommand().name()
3016
+ ) {
2807
3017
  operands.push(arg);
2808
3018
  if (args.length > 0) operands.push(...args);
2809
3019
  break;
@@ -2831,7 +3041,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2831
3041
  /**
2832
3042
  * Return an object containing local option values as key-value pairs.
2833
3043
  *
2834
- * @return {Object}
3044
+ * @return {object}
2835
3045
  */
2836
3046
  opts() {
2837
3047
  if (this._storeOptionsAsProperties) {
@@ -2841,7 +3051,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
2841
3051
 
2842
3052
  for (let i = 0; i < len; i++) {
2843
3053
  const key = this.options[i].attributeName();
2844
- result[key] = key === this._versionOptionName ? this._version : this[key];
3054
+ result[key] =
3055
+ key === this._versionOptionName ? this._version : this[key];
2845
3056
  }
2846
3057
  return result;
2847
3058
  }
@@ -2852,13 +3063,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
2852
3063
  /**
2853
3064
  * Return an object containing merged local and global option values as key-value pairs.
2854
3065
  *
2855
- * @return {Object}
3066
+ * @return {object}
2856
3067
  */
2857
3068
  optsWithGlobals() {
2858
3069
  // globals overwrite locals
2859
3070
  return this._getCommandAndAncestors().reduce(
2860
3071
  (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
2861
- {}
3072
+ {},
2862
3073
  );
2863
3074
  }
2864
3075
 
@@ -2866,13 +3077,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
2866
3077
  * Display error message and exit (or call exitOverride).
2867
3078
  *
2868
3079
  * @param {string} message
2869
- * @param {Object} [errorOptions]
3080
+ * @param {object} [errorOptions]
2870
3081
  * @param {string} [errorOptions.code] - an id string representing the error
2871
3082
  * @param {number} [errorOptions.exitCode] - used with process.exit
2872
3083
  */
2873
3084
  error(message, errorOptions) {
2874
3085
  // output handling
2875
- this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr);
3086
+ this._outputConfiguration.outputError(
3087
+ `${message}\n`,
3088
+ this._outputConfiguration.writeErr,
3089
+ );
2876
3090
  if (typeof this._showHelpAfterError === 'string') {
2877
3091
  this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`);
2878
3092
  } else if (this._showHelpAfterError) {
@@ -2898,11 +3112,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2898
3112
  if (option.envVar && option.envVar in process$2.env) {
2899
3113
  const optionKey = option.attributeName();
2900
3114
  // Priority check. Do not overwrite cli or options from unknown source (client-code).
2901
- if (this.getOptionValue(optionKey) === undefined || ['default', 'config', 'env'].includes(this.getOptionValueSource(optionKey))) {
2902
- if (option.required || option.optional) { // option can take a value
3115
+ if (
3116
+ this.getOptionValue(optionKey) === undefined ||
3117
+ ['default', 'config', 'env'].includes(
3118
+ this.getOptionValueSource(optionKey),
3119
+ )
3120
+ ) {
3121
+ if (option.required || option.optional) {
3122
+ // option can take a value
2903
3123
  // keep very simple, optional always takes value
2904
3124
  this.emit(`optionEnv:${option.name()}`, process$2.env[option.envVar]);
2905
- } else { // boolean
3125
+ } else {
3126
+ // boolean
2906
3127
  // keep very simple, only care that envVar defined and not the value
2907
3128
  this.emit(`optionEnv:${option.name()}`);
2908
3129
  }
@@ -2919,17 +3140,30 @@ Expecting one of '${allowedValues.join("', '")}'`);
2919
3140
  _parseOptionsImplied() {
2920
3141
  const dualHelper = new DualOptions(this.options);
2921
3142
  const hasCustomOptionValue = (optionKey) => {
2922
- return this.getOptionValue(optionKey) !== undefined && !['default', 'implied'].includes(this.getOptionValueSource(optionKey));
3143
+ return (
3144
+ this.getOptionValue(optionKey) !== undefined &&
3145
+ !['default', 'implied'].includes(this.getOptionValueSource(optionKey))
3146
+ );
2923
3147
  };
2924
3148
  this.options
2925
- .filter(option => (option.implied !== undefined) &&
2926
- hasCustomOptionValue(option.attributeName()) &&
2927
- dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option))
3149
+ .filter(
3150
+ (option) =>
3151
+ option.implied !== undefined &&
3152
+ hasCustomOptionValue(option.attributeName()) &&
3153
+ dualHelper.valueFromOption(
3154
+ this.getOptionValue(option.attributeName()),
3155
+ option,
3156
+ ),
3157
+ )
2928
3158
  .forEach((option) => {
2929
3159
  Object.keys(option.implied)
2930
- .filter(impliedKey => !hasCustomOptionValue(impliedKey))
2931
- .forEach(impliedKey => {
2932
- this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied');
3160
+ .filter((impliedKey) => !hasCustomOptionValue(impliedKey))
3161
+ .forEach((impliedKey) => {
3162
+ this.setOptionValueWithSource(
3163
+ impliedKey,
3164
+ option.implied[impliedKey],
3165
+ 'implied',
3166
+ );
2933
3167
  });
2934
3168
  });
2935
3169
  }
@@ -2983,12 +3217,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2983
3217
  const findBestOptionFromValue = (option) => {
2984
3218
  const optionKey = option.attributeName();
2985
3219
  const optionValue = this.getOptionValue(optionKey);
2986
- const negativeOption = this.options.find(target => target.negate && optionKey === target.attributeName());
2987
- const positiveOption = this.options.find(target => !target.negate && optionKey === target.attributeName());
2988
- if (negativeOption && (
2989
- (negativeOption.presetArg === undefined && optionValue === false) ||
2990
- (negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)
2991
- )) {
3220
+ const negativeOption = this.options.find(
3221
+ (target) => target.negate && optionKey === target.attributeName(),
3222
+ );
3223
+ const positiveOption = this.options.find(
3224
+ (target) => !target.negate && optionKey === target.attributeName(),
3225
+ );
3226
+ if (
3227
+ negativeOption &&
3228
+ ((negativeOption.presetArg === undefined && optionValue === false) ||
3229
+ (negativeOption.presetArg !== undefined &&
3230
+ optionValue === negativeOption.presetArg))
3231
+ ) {
2992
3232
  return negativeOption;
2993
3233
  }
2994
3234
  return positiveOption || option;
@@ -3022,11 +3262,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
3022
3262
  if (flag.startsWith('--') && this._showSuggestionAfterError) {
3023
3263
  // Looping to pick up the global options too
3024
3264
  let candidateFlags = [];
3265
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
3025
3266
  let command = this;
3026
3267
  do {
3027
- const moreFlags = command.createHelp().visibleOptions(command)
3028
- .filter(option => option.long)
3029
- .map(option => option.long);
3268
+ const moreFlags = command
3269
+ .createHelp()
3270
+ .visibleOptions(command)
3271
+ .filter((option) => option.long)
3272
+ .map((option) => option.long);
3030
3273
  candidateFlags = candidateFlags.concat(moreFlags);
3031
3274
  command = command.parent;
3032
3275
  } while (command && !command._enablePositionalOptions);
@@ -3048,7 +3291,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3048
3291
  if (this._allowExcessArguments) return;
3049
3292
 
3050
3293
  const expected = this.registeredArguments.length;
3051
- const s = (expected === 1) ? '' : 's';
3294
+ const s = expected === 1 ? '' : 's';
3052
3295
  const forSubcommand = this.parent ? ` for '${this.name()}'` : '';
3053
3296
  const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
3054
3297
  this.error(message, { code: 'commander.excessArguments' });
@@ -3066,11 +3309,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
3066
3309
 
3067
3310
  if (this._showSuggestionAfterError) {
3068
3311
  const candidateNames = [];
3069
- this.createHelp().visibleCommands(this).forEach((command) => {
3070
- candidateNames.push(command.name());
3071
- // just visible alias
3072
- if (command.alias()) candidateNames.push(command.alias());
3073
- });
3312
+ this.createHelp()
3313
+ .visibleCommands(this)
3314
+ .forEach((command) => {
3315
+ candidateNames.push(command.name());
3316
+ // just visible alias
3317
+ if (command.alias()) candidateNames.push(command.alias());
3318
+ });
3074
3319
  suggestion = suggestSimilar(unknownName, candidateNames);
3075
3320
  }
3076
3321
 
@@ -3111,11 +3356,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
3111
3356
  * Set the description.
3112
3357
  *
3113
3358
  * @param {string} [str]
3114
- * @param {Object} [argsDescription]
3359
+ * @param {object} [argsDescription]
3115
3360
  * @return {(string|Command)}
3116
3361
  */
3117
3362
  description(str, argsDescription) {
3118
- if (str === undefined && argsDescription === undefined) return this._description;
3363
+ if (str === undefined && argsDescription === undefined)
3364
+ return this._description;
3119
3365
  this._description = str;
3120
3366
  if (argsDescription) {
3121
3367
  this._argsDescription = argsDescription;
@@ -3148,18 +3394,27 @@ Expecting one of '${allowedValues.join("', '")}'`);
3148
3394
  if (alias === undefined) return this._aliases[0]; // just return first, for backwards compatibility
3149
3395
 
3150
3396
  /** @type {Command} */
3397
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
3151
3398
  let command = this;
3152
- if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
3399
+ if (
3400
+ this.commands.length !== 0 &&
3401
+ this.commands[this.commands.length - 1]._executableHandler
3402
+ ) {
3153
3403
  // assume adding alias for last added executable subcommand, rather than this
3154
3404
  command = this.commands[this.commands.length - 1];
3155
3405
  }
3156
3406
 
3157
- if (alias === command._name) throw new Error('Command alias can\'t be the same as its name');
3407
+ if (alias === command._name)
3408
+ throw new Error("Command alias can't be the same as its name");
3158
3409
  const matchingCommand = this.parent?._findCommand(alias);
3159
3410
  if (matchingCommand) {
3160
3411
  // c.f. _registerCommand
3161
- const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join('|');
3162
- throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`);
3412
+ const existingCmd = [matchingCommand.name()]
3413
+ .concat(matchingCommand.aliases())
3414
+ .join('|');
3415
+ throw new Error(
3416
+ `cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`,
3417
+ );
3163
3418
  }
3164
3419
 
3165
3420
  command._aliases.push(alias);
@@ -3197,11 +3452,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
3197
3452
  const args = this.registeredArguments.map((arg) => {
3198
3453
  return humanReadableArgName(arg);
3199
3454
  });
3200
- return [].concat(
3201
- (this.options.length || (this._helpOption !== null) ? '[options]' : []),
3202
- (this.commands.length ? '[command]' : []),
3203
- (this.registeredArguments.length ? args : [])
3204
- ).join(' ');
3455
+ return []
3456
+ .concat(
3457
+ this.options.length || this._helpOption !== null ? '[options]' : [],
3458
+ this.commands.length ? '[command]' : [],
3459
+ this.registeredArguments.length ? args : [],
3460
+ )
3461
+ .join(' ');
3205
3462
  }
3206
3463
 
3207
3464
  this._usage = str;
@@ -3268,7 +3525,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
3268
3525
  helpInformation(contextOptions) {
3269
3526
  const helper = this.createHelp();
3270
3527
  if (helper.helpWidth === undefined) {
3271
- helper.helpWidth = (contextOptions && contextOptions.error) ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
3528
+ helper.helpWidth =
3529
+ contextOptions && contextOptions.error
3530
+ ? this._outputConfiguration.getErrHelpWidth()
3531
+ : this._outputConfiguration.getOutHelpWidth();
3272
3532
  }
3273
3533
  return helper.formatHelp(this, helper);
3274
3534
  }
@@ -3307,13 +3567,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
3307
3567
  }
3308
3568
  const context = this._getHelpContext(contextOptions);
3309
3569
 
3310
- this._getCommandAndAncestors().reverse().forEach(command => command.emit('beforeAllHelp', context));
3570
+ this._getCommandAndAncestors()
3571
+ .reverse()
3572
+ .forEach((command) => command.emit('beforeAllHelp', context));
3311
3573
  this.emit('beforeHelp', context);
3312
3574
 
3313
3575
  let helpInformation = this.helpInformation(context);
3314
3576
  if (deprecatedCallback) {
3315
3577
  helpInformation = deprecatedCallback(helpInformation);
3316
- if (typeof helpInformation !== 'string' && !Buffer.isBuffer(helpInformation)) {
3578
+ if (
3579
+ typeof helpInformation !== 'string' &&
3580
+ !Buffer.isBuffer(helpInformation)
3581
+ ) {
3317
3582
  throw new Error('outputHelp callback must return a string or a Buffer');
3318
3583
  }
3319
3584
  }
@@ -3323,7 +3588,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3323
3588
  this.emit(this._getHelpOption().long); // deprecated
3324
3589
  }
3325
3590
  this.emit('afterHelp', context);
3326
- this._getCommandAndAncestors().forEach(command => command.emit('afterAllHelp', context));
3591
+ this._getCommandAndAncestors().forEach((command) =>
3592
+ command.emit('afterAllHelp', context),
3593
+ );
3327
3594
  }
3328
3595
 
3329
3596
  /**
@@ -3363,7 +3630,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3363
3630
  * Returns null if has been disabled with .helpOption(false).
3364
3631
  *
3365
3632
  * @returns {(Option | null)} the help option
3366
- * @package internal use only
3633
+ * @package
3367
3634
  */
3368
3635
  _getHelpOption() {
3369
3636
  // Lazy create help option on demand.
@@ -3396,7 +3663,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
3396
3663
  help(contextOptions) {
3397
3664
  this.outputHelp(contextOptions);
3398
3665
  let exitCode = process$2.exitCode || 0;
3399
- if (exitCode === 0 && contextOptions && typeof contextOptions !== 'function' && contextOptions.error) {
3666
+ if (
3667
+ exitCode === 0 &&
3668
+ contextOptions &&
3669
+ typeof contextOptions !== 'function' &&
3670
+ contextOptions.error
3671
+ ) {
3400
3672
  exitCode = 1;
3401
3673
  }
3402
3674
  // message: do not have all displayed text available so only passing placeholder.
@@ -3444,7 +3716,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3444
3716
 
3445
3717
  _outputHelpIfRequested(args) {
3446
3718
  const helpOption = this._getHelpOption();
3447
- const helpRequested = helpOption && args.find(arg => helpOption.is(arg));
3719
+ const helpRequested = helpOption && args.find((arg) => helpOption.is(arg));
3448
3720
  if (helpRequested) {
3449
3721
  this.outputHelp();
3450
3722
  // (Do not have all displayed text available so only passing placeholder.)
@@ -3477,7 +3749,9 @@ function incrementNodeInspectorPort(args) {
3477
3749
  if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
3478
3750
  // e.g. --inspect
3479
3751
  debugOption = match[1];
3480
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
3752
+ } else if (
3753
+ (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null
3754
+ ) {
3481
3755
  debugOption = match[1];
3482
3756
  if (/^\d+$/.test(match[3])) {
3483
3757
  // e.g. --inspect=1234
@@ -3486,7 +3760,9 @@ function incrementNodeInspectorPort(args) {
3486
3760
  // e.g. --inspect=localhost
3487
3761
  debugHost = match[3];
3488
3762
  }
3489
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
3763
+ } else if (
3764
+ (match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null
3765
+ ) {
3490
3766
  // e.g. --inspect=localhost:1234
3491
3767
  debugOption = match[1];
3492
3768
  debugHost = match[3];
@@ -3530,8 +3806,6 @@ commander.InvalidOptionArgumentError = InvalidArgumentError$1; // Deprecated
3530
3806
  (function (module, exports) {
3531
3807
  const commander$1 = commander;
3532
3808
 
3533
- // @ts-check
3534
-
3535
3809
  exports = module.exports = {};
3536
3810
 
3537
3811
  // Return a different global program than commander,
@@ -3554,8 +3828,10 @@ commander.InvalidOptionArgumentError = InvalidArgumentError$1; // Deprecated
3554
3828
  // methods on the global program due to the (deprecated) legacy default export.
3555
3829
  // Here we roll our own, the way Commander might in future.
3556
3830
  exports.createCommand = (name) => new commander$1.Command(name);
3557
- exports.createOption = (flags, description) => new commander$1.Option(flags, description);
3558
- exports.createArgument = (name, description) => new commander$1.Argument(name, description);
3831
+ exports.createOption = (flags, description) =>
3832
+ new commander$1.Option(flags, description);
3833
+ exports.createArgument = (name, description) =>
3834
+ new commander$1.Argument(name, description);
3559
3835
  } (extraTypings, extraTypings.exports));
3560
3836
 
3561
3837
  var extraTypingsExports = extraTypings.exports;
@@ -3573,7 +3849,7 @@ const {
3573
3849
  Command,
3574
3850
  Argument,
3575
3851
  Option,
3576
- Help
3852
+ Help,
3577
3853
  } = extraTypingsCommander;
3578
3854
 
3579
3855
  function isPlainObject(value) {
@@ -4439,7 +4715,7 @@ function requireWindows () {
4439
4715
  windows = isexe;
4440
4716
  isexe.sync = sync;
4441
4717
 
4442
- var fs = require$$0$2;
4718
+ var fs = require$$0$1;
4443
4719
 
4444
4720
  function checkPathExt (path, options) {
4445
4721
  var pathext = options.pathExt !== undefined ?
@@ -4490,7 +4766,7 @@ function requireMode () {
4490
4766
  mode = isexe;
4491
4767
  isexe.sync = sync;
4492
4768
 
4493
- var fs = require$$0$2;
4769
+ var fs = require$$0$1;
4494
4770
 
4495
4771
  function isexe (path, options, cb) {
4496
4772
  fs.stat(path, function (er, stat) {
@@ -4592,7 +4868,7 @@ const isWindows = process.platform === 'win32' ||
4592
4868
  process.env.OSTYPE === 'cygwin' ||
4593
4869
  process.env.OSTYPE === 'msys';
4594
4870
 
4595
- const path$q = require$$0$1;
4871
+ const path$q = require$$0$2;
4596
4872
  const COLON = isWindows ? ';' : ':';
4597
4873
  const isexe = isexe_1;
4598
4874
 
@@ -4733,7 +5009,7 @@ pathKey$2.exports.default = pathKey$1;
4733
5009
 
4734
5010
  var pathKeyExports = pathKey$2.exports;
4735
5011
 
4736
- const path$p = require$$0$1;
5012
+ const path$p = require$$0$2;
4737
5013
  const which = which_1;
4738
5014
  const getPathKey = pathKeyExports;
4739
5015
 
@@ -4851,7 +5127,7 @@ var shebangCommand$1 = (string = '') => {
4851
5127
  return argument ? `${binary} ${argument}` : binary;
4852
5128
  };
4853
5129
 
4854
- const fs$t = require$$0$2;
5130
+ const fs$t = require$$0$1;
4855
5131
  const shebangCommand = shebangCommand$1;
4856
5132
 
4857
5133
  function readShebang$1(command) {
@@ -4873,7 +5149,7 @@ function readShebang$1(command) {
4873
5149
 
4874
5150
  var readShebang_1 = readShebang$1;
4875
5151
 
4876
- const path$o = require$$0$1;
5152
+ const path$o = require$$0$2;
4877
5153
  const resolveCommand = resolveCommand_1;
4878
5154
  const escape = _escape;
4879
5155
  const readShebang = readShebang_1;
@@ -5021,7 +5297,7 @@ var enoent$1 = {
5021
5297
  notFoundError,
5022
5298
  };
5023
5299
 
5024
- const cp = require$$1;
5300
+ const cp = require$$0$3;
5025
5301
  const parse$5 = parse_1$3;
5026
5302
  const enoent = enoent$1;
5027
5303
 
@@ -28396,7 +28672,7 @@ universalify$1.fromPromise = function (fn) {
28396
28672
  }, 'name', { value: fn.name })
28397
28673
  };
28398
28674
 
28399
- var constants$5 = require$$0$3;
28675
+ var constants$5 = require$$0$4;
28400
28676
 
28401
28677
  var origCwd = process.cwd;
28402
28678
  var cwd = null;
@@ -28752,7 +29028,7 @@ function patch$1 (fs) {
28752
29028
  }
28753
29029
  }
28754
29030
 
28755
- var Stream$1 = require$$0$4.Stream;
29031
+ var Stream$1 = require$$0$5.Stream;
28756
29032
 
28757
29033
  var legacyStreams = legacy$1;
28758
29034
 
@@ -28893,12 +29169,12 @@ function clone$1 (obj) {
28893
29169
  return copy
28894
29170
  }
28895
29171
 
28896
- var fs$r = require$$0$2;
29172
+ var fs$r = require$$0$1;
28897
29173
  var polyfills = polyfills$1;
28898
29174
  var legacy = legacyStreams;
28899
29175
  var clone = clone_1;
28900
29176
 
28901
- var util$2 = require$$0$5;
29177
+ var util$2 = require$$0$6;
28902
29178
 
28903
29179
  /* istanbul ignore next - node 0.x polyfill */
28904
29180
  var gracefulQueue;
@@ -29488,7 +29764,7 @@ var makeDir$1 = {};
29488
29764
 
29489
29765
  var utils$m = {};
29490
29766
 
29491
- const path$n = require$$0$1;
29767
+ const path$n = require$$0$2;
29492
29768
 
29493
29769
  // https://github.com/nodejs/node/issues/8987
29494
29770
  // https://github.com/libuv/libuv/pull/1088
@@ -29593,7 +29869,7 @@ var utimes = {
29593
29869
  };
29594
29870
 
29595
29871
  const fs$n = fs$s;
29596
- const path$m = require$$0$1;
29872
+ const path$m = require$$0$2;
29597
29873
  const u$b = universalify$1.fromPromise;
29598
29874
 
29599
29875
  function getStats$1 (src, dest, opts) {
@@ -29750,7 +30026,7 @@ var stat$5 = {
29750
30026
  };
29751
30027
 
29752
30028
  const fs$m = fs$s;
29753
- const path$l = require$$0$1;
30029
+ const path$l = require$$0$2;
29754
30030
  const { mkdirs: mkdirs$1 } = mkdirs$2;
29755
30031
  const { pathExists: pathExists$5 } = pathExists_1;
29756
30032
  const { utimesMillis } = utimes;
@@ -29926,7 +30202,7 @@ async function onLink$1 (destStat, src, dest, opts) {
29926
30202
  var copy_1 = copy$2;
29927
30203
 
29928
30204
  const fs$l = gracefulFs;
29929
- const path$k = require$$0$1;
30205
+ const path$k = require$$0$2;
29930
30206
  const mkdirsSync$1 = mkdirs$2.mkdirsSync;
29931
30207
  const utimesMillisSync = utimes.utimesMillisSync;
29932
30208
  const stat$3 = stat$5;
@@ -30109,7 +30385,7 @@ var remove_1 = {
30109
30385
 
30110
30386
  const u$8 = universalify$1.fromPromise;
30111
30387
  const fs$j = fs$s;
30112
- const path$j = require$$0$1;
30388
+ const path$j = require$$0$2;
30113
30389
  const mkdir$3 = mkdirs$2;
30114
30390
  const remove$1 = remove_1;
30115
30391
 
@@ -30146,7 +30422,7 @@ var empty = {
30146
30422
  };
30147
30423
 
30148
30424
  const u$7 = universalify$1.fromPromise;
30149
- const path$i = require$$0$1;
30425
+ const path$i = require$$0$2;
30150
30426
  const fs$i = fs$s;
30151
30427
  const mkdir$2 = mkdirs$2;
30152
30428
 
@@ -30211,7 +30487,7 @@ var file = {
30211
30487
  };
30212
30488
 
30213
30489
  const u$6 = universalify$1.fromPromise;
30214
- const path$h = require$$0$1;
30490
+ const path$h = require$$0$2;
30215
30491
  const fs$h = fs$s;
30216
30492
  const mkdir$1 = mkdirs$2;
30217
30493
  const { pathExists: pathExists$4 } = pathExists_1;
@@ -30273,7 +30549,7 @@ var link = {
30273
30549
  createLinkSync: createLinkSync$1
30274
30550
  };
30275
30551
 
30276
- const path$g = require$$0$1;
30552
+ const path$g = require$$0$2;
30277
30553
  const fs$g = fs$s;
30278
30554
  const { pathExists: pathExists$3 } = pathExists_1;
30279
30555
 
@@ -30407,7 +30683,7 @@ var symlinkType_1 = {
30407
30683
  };
30408
30684
 
30409
30685
  const u$3 = universalify$1.fromPromise;
30410
- const path$f = require$$0$1;
30686
+ const path$f = require$$0$2;
30411
30687
  const fs$e = fs$s;
30412
30688
 
30413
30689
  const { mkdirs, mkdirsSync } = mkdirs$2;
@@ -30513,7 +30789,7 @@ let _fs;
30513
30789
  try {
30514
30790
  _fs = gracefulFs;
30515
30791
  } catch (_) {
30516
- _fs = require$$0$2;
30792
+ _fs = require$$0$1;
30517
30793
  }
30518
30794
  const universalify = universalify$1;
30519
30795
  const { stringify: stringify$7, stripBom } = utils$l;
@@ -30610,7 +30886,7 @@ var jsonfile = {
30610
30886
 
30611
30887
  const u$2 = universalify$1.fromPromise;
30612
30888
  const fs$d = fs$s;
30613
- const path$e = require$$0$1;
30889
+ const path$e = require$$0$2;
30614
30890
  const mkdir = mkdirs$2;
30615
30891
  const pathExists$1 = pathExists_1.pathExists;
30616
30892
 
@@ -30676,7 +30952,7 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
30676
30952
  var json = jsonFile;
30677
30953
 
30678
30954
  const fs$c = fs$s;
30679
- const path$d = require$$0$1;
30955
+ const path$d = require$$0$2;
30680
30956
  const { copy } = copy$1;
30681
30957
  const { remove } = remove_1;
30682
30958
  const { mkdirp } = mkdirs$2;
@@ -30734,7 +31010,7 @@ async function moveAcrossDevice$1 (src, dest, overwrite) {
30734
31010
  var move_1 = move$1;
30735
31011
 
30736
31012
  const fs$b = gracefulFs;
30737
- const path$c = require$$0$1;
31013
+ const path$c = require$$0$2;
30738
31014
  const copySync = copy$1.copySync;
30739
31015
  const removeSync = remove_1.removeSync;
30740
31016
  const mkdirpSync = mkdirs$2.mkdirpSync;
@@ -30999,8 +31275,8 @@ var require$$4 = {
30999
31275
  browser: browser
31000
31276
  };
31001
31277
 
31002
- const fs$9 = require$$0$2;
31003
- const path$b = require$$0$1;
31278
+ const fs$9 = require$$0$1;
31279
+ const path$b = require$$0$2;
31004
31280
  const os$1 = require$$2;
31005
31281
  const crypto = require$$3;
31006
31282
  const packageJson = require$$4;
@@ -31390,16 +31666,16 @@ const getDotenv = async (options = {}) => {
31390
31666
  ? await paths.reduce(async (e, p) => {
31391
31667
  const publicGlobal = excludePublic || excludeGlobal
31392
31668
  ? Promise.resolve({})
31393
- : readDotenv(require$$0$1.resolve(p, dotenvToken));
31669
+ : readDotenv(require$$0$2.resolve(p, dotenvToken));
31394
31670
  const publicEnv = excludePublic || excludeEnv || (!env && !defaultEnv)
31395
31671
  ? Promise.resolve({})
31396
- : readDotenv(require$$0$1.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}`));
31672
+ : readDotenv(require$$0$2.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}`));
31397
31673
  const privateGlobal = excludePrivate || excludeGlobal
31398
31674
  ? Promise.resolve({})
31399
- : readDotenv(require$$0$1.resolve(p, `${dotenvToken}.${privateToken}`));
31675
+ : readDotenv(require$$0$2.resolve(p, `${dotenvToken}.${privateToken}`));
31400
31676
  const privateEnv = excludePrivate || excludeEnv || (!env && !defaultEnv)
31401
31677
  ? Promise.resolve({})
31402
- : readDotenv(require$$0$1.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}.${privateToken}`));
31678
+ : readDotenv(require$$0$2.resolve(p, `${dotenvToken}.${env ?? defaultEnv ?? ''}.${privateToken}`));
31403
31679
  const [eResolved, publicGlobalResolved, publicEnvResolved, privateGlobalResolved, privateEnvResolved,] = await Promise.all([
31404
31680
  e,
31405
31681
  publicGlobal,
@@ -31424,7 +31700,7 @@ const getDotenv = async (options = {}) => {
31424
31700
  }, { progressive: true });
31425
31701
  // Process dynamic variables.
31426
31702
  if (dynamicPath && !excludeDynamic) {
31427
- const absDynamicPath = require$$0$1.resolve(dynamicPath);
31703
+ const absDynamicPath = require$$0$2.resolve(dynamicPath);
31428
31704
  if (await fs$a.exists(absDynamicPath)) {
31429
31705
  try {
31430
31706
  const { default: dynamic } = (await import(url.pathToFileURL(absDynamicPath).toString()));
@@ -31468,7 +31744,7 @@ const getDotenv = async (options = {}) => {
31468
31744
  * Copyright (c) 2014-2020 Teambition
31469
31745
  * Licensed under the MIT license.
31470
31746
  */
31471
- const Stream = require$$0$4;
31747
+ const Stream = require$$0$5;
31472
31748
  const PassThrough = Stream.PassThrough;
31473
31749
  const slice = Array.prototype.slice;
31474
31750
 
@@ -31668,7 +31944,7 @@ var path$a = {};
31668
31944
  Object.defineProperty(path$a, "__esModule", { value: true });
31669
31945
  path$a.convertPosixPathToPattern = path$a.convertWindowsPathToPattern = path$a.convertPathToPattern = path$a.escapePosixPath = path$a.escapeWindowsPath = path$a.escape = path$a.removeLeadingDotSegment = path$a.makeAbsolute = path$a.unixify = void 0;
31670
31946
  const os = require$$2;
31671
- const path$9 = require$$0$1;
31947
+ const path$9 = require$$0$2;
31672
31948
  const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
31673
31949
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
31674
31950
  /**
@@ -31908,7 +32184,7 @@ var isGlob$1 = function isGlob(str, options) {
31908
32184
  };
31909
32185
 
31910
32186
  var isGlob = isGlob$1;
31911
- var pathPosixDirname = require$$0$1.posix.dirname;
32187
+ var pathPosixDirname = require$$0$2.posix.dirname;
31912
32188
  var isWin32 = require$$2.platform() === 'win32';
31913
32189
 
31914
32190
  var slash$1 = '/';
@@ -32405,7 +32681,7 @@ var toRegexRange_1 = toRegexRange$1;
32405
32681
  * Licensed under the MIT License.
32406
32682
  */
32407
32683
 
32408
- const util$1 = require$$0$5;
32684
+ const util$1 = require$$0$6;
32409
32685
  const toRegexRange = toRegexRange_1;
32410
32686
 
32411
32687
  const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
@@ -33370,7 +33646,7 @@ var braces_1 = braces$1;
33370
33646
 
33371
33647
  var utils$f = {};
33372
33648
 
33373
- const path$8 = require$$0$1;
33649
+ const path$8 = require$$0$2;
33374
33650
  const WIN_SLASH = '\\\\/';
33375
33651
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
33376
33652
 
@@ -33550,7 +33826,7 @@ var constants$3 = {
33550
33826
 
33551
33827
  (function (exports) {
33552
33828
 
33553
- const path = require$$0$1;
33829
+ const path = require$$0$2;
33554
33830
  const win32 = process.platform === 'win32';
33555
33831
  const {
33556
33832
  REGEX_BACKSLASH,
@@ -35094,7 +35370,7 @@ parse$1.fastpaths = (input, options) => {
35094
35370
 
35095
35371
  var parse_1 = parse$1;
35096
35372
 
35097
- const path$7 = require$$0$1;
35373
+ const path$7 = require$$0$2;
35098
35374
  const scan = scan_1;
35099
35375
  const parse = parse_1;
35100
35376
  const utils$c = utils$f;
@@ -35437,7 +35713,7 @@ var picomatch_1 = picomatch$2;
35437
35713
 
35438
35714
  var picomatch$1 = picomatch_1;
35439
35715
 
35440
- const util = require$$0$5;
35716
+ const util = require$$0$6;
35441
35717
  const braces = braces_1;
35442
35718
  const picomatch = picomatch$1;
35443
35719
  const utils$b = utils$f;
@@ -35905,7 +36181,7 @@ var micromatch_1 = micromatch$1;
35905
36181
 
35906
36182
  Object.defineProperty(pattern$1, "__esModule", { value: true });
35907
36183
  pattern$1.removeDuplicateSlashes = pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
35908
- const path$6 = require$$0$1;
36184
+ const path$6 = require$$0$2;
35909
36185
  const globParent = globParent$1;
35910
36186
  const micromatch = micromatch_1;
35911
36187
  const GLOBSTAR = '**';
@@ -36336,7 +36612,7 @@ var fs$6 = {};
36336
36612
  (function (exports) {
36337
36613
  Object.defineProperty(exports, "__esModule", { value: true });
36338
36614
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
36339
- const fs = require$$0$2;
36615
+ const fs = require$$0$1;
36340
36616
  exports.FILE_SYSTEM_ADAPTER = {
36341
36617
  lstat: fs.lstat,
36342
36618
  stat: fs.stat,
@@ -36687,7 +36963,7 @@ var fs$2 = {};
36687
36963
  (function (exports) {
36688
36964
  Object.defineProperty(exports, "__esModule", { value: true });
36689
36965
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
36690
- const fs = require$$0$2;
36966
+ const fs = require$$0$1;
36691
36967
  exports.FILE_SYSTEM_ADAPTER = {
36692
36968
  lstat: fs.lstat,
36693
36969
  stat: fs.stat,
@@ -36706,7 +36982,7 @@ var fs$2 = {};
36706
36982
  } (fs$2));
36707
36983
 
36708
36984
  Object.defineProperty(settings$2, "__esModule", { value: true });
36709
- const path$4 = require$$0$1;
36985
+ const path$4 = require$$0$2;
36710
36986
  const fsStat$3 = out$1;
36711
36987
  const fs$1 = fs$2;
36712
36988
  let Settings$1 = class Settings {
@@ -37148,7 +37424,7 @@ let Reader$1 = class Reader {
37148
37424
  reader$1.default = Reader$1;
37149
37425
 
37150
37426
  Object.defineProperty(async$4, "__esModule", { value: true });
37151
- const events_1 = require$$0;
37427
+ const events_1 = require$$0$7;
37152
37428
  const fsScandir$2 = out$2;
37153
37429
  const fastq = queueExports;
37154
37430
  const common$1 = common$3;
@@ -37277,7 +37553,7 @@ function callSuccessCallback(callback, entries) {
37277
37553
  var stream$2 = {};
37278
37554
 
37279
37555
  Object.defineProperty(stream$2, "__esModule", { value: true });
37280
- const stream_1$5 = require$$0$4;
37556
+ const stream_1$5 = require$$0$5;
37281
37557
  const async_1$3 = async$4;
37282
37558
  class StreamProvider {
37283
37559
  constructor(_root, _settings) {
@@ -37390,7 +37666,7 @@ sync$3.default = SyncProvider;
37390
37666
  var settings$1 = {};
37391
37667
 
37392
37668
  Object.defineProperty(settings$1, "__esModule", { value: true });
37393
- const path$3 = require$$0$1;
37669
+ const path$3 = require$$0$2;
37394
37670
  const fsScandir = out$2;
37395
37671
  class Settings {
37396
37672
  constructor(_options = {}) {
@@ -37452,7 +37728,7 @@ function getSettings(settingsOrOptions = {}) {
37452
37728
  var reader = {};
37453
37729
 
37454
37730
  Object.defineProperty(reader, "__esModule", { value: true });
37455
- const path$2 = require$$0$1;
37731
+ const path$2 = require$$0$2;
37456
37732
  const fsStat$2 = out$1;
37457
37733
  const utils$6 = utils$k;
37458
37734
  class Reader {
@@ -37487,7 +37763,7 @@ reader.default = Reader;
37487
37763
  var stream$1 = {};
37488
37764
 
37489
37765
  Object.defineProperty(stream$1, "__esModule", { value: true });
37490
- const stream_1$3 = require$$0$4;
37766
+ const stream_1$3 = require$$0$5;
37491
37767
  const fsStat$1 = out$1;
37492
37768
  const fsWalk$2 = out$3;
37493
37769
  const reader_1$2 = reader;
@@ -37840,7 +38116,7 @@ class EntryTransformer {
37840
38116
  entry.default = EntryTransformer;
37841
38117
 
37842
38118
  Object.defineProperty(provider, "__esModule", { value: true });
37843
- const path$1 = require$$0$1;
38119
+ const path$1 = require$$0$2;
37844
38120
  const deep_1 = deep;
37845
38121
  const entry_1 = entry$1;
37846
38122
  const error_1 = error;
@@ -37913,7 +38189,7 @@ async$7.default = ProviderAsync;
37913
38189
  var stream = {};
37914
38190
 
37915
38191
  Object.defineProperty(stream, "__esModule", { value: true });
37916
- const stream_1$1 = require$$0$4;
38192
+ const stream_1$1 = require$$0$5;
37917
38193
  const stream_2 = stream$1;
37918
38194
  const provider_1$1 = provider;
37919
38195
  class ProviderStream extends provider_1$1.default {
@@ -38018,7 +38294,7 @@ var settings = {};
38018
38294
  (function (exports) {
38019
38295
  Object.defineProperty(exports, "__esModule", { value: true });
38020
38296
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
38021
- const fs = require$$0$2;
38297
+ const fs = require$$0$1;
38022
38298
  const os = require$$2;
38023
38299
  /**
38024
38300
  * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
@@ -38182,8 +38458,8 @@ var dirGlob$1 = {exports: {}};
38182
38458
 
38183
38459
  var pathType$1 = {};
38184
38460
 
38185
- const {promisify} = require$$0$5;
38186
- const fs = require$$0$2;
38461
+ const {promisify} = require$$0$6;
38462
+ const fs = require$$0$1;
38187
38463
 
38188
38464
  async function isType(fsStatType, statsMethodName, filePath) {
38189
38465
  if (typeof filePath !== 'string') {
@@ -38225,7 +38501,7 @@ pathType$1.isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
38225
38501
  pathType$1.isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
38226
38502
  pathType$1.isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
38227
38503
 
38228
- const path = require$$0$1;
38504
+ const path = require$$0$2;
38229
38505
  const pathType = pathType$1;
38230
38506
 
38231
38507
  const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
@@ -39189,7 +39465,7 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
39189
39465
  }
39190
39466
  cwd = pkgDir;
39191
39467
  }
39192
- const absRootPath = require$$0$1.posix.join(cwd.split(require$$0$1.sep).join(require$$0$1.posix.sep), rootPath.split(require$$0$1.sep).join(require$$0$1.posix.sep));
39468
+ const absRootPath = require$$0$2.posix.join(cwd.split(require$$0$2.sep).join(require$$0$2.posix.sep), rootPath.split(require$$0$2.sep).join(require$$0$2.posix.sep));
39193
39469
  const paths = await globby(globs.split(/\s+/), {
39194
39470
  cwd: absRootPath,
39195
39471
  expandDirectories: false,
@@ -39502,4 +39778,4 @@ const generateGetDotenvCli = async (customOptions) => {
39502
39778
  });
39503
39779
  };
39504
39780
 
39505
- export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
39781
+ export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };