@karmaniverous/get-dotenv 4.3.0 → 4.3.2

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