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