Skip to content
Myr

command.exitOverride.test.js

This file

Path

tests/command.exitOverride.test.js

457 lines · 12.6 KiB · JavaScript

Last changed by

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

History of this file

Take it

The walk stopped after 200 commits: lines older than 1b492d9 point at it.

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 1–2why, one step back
1const commander = require('../');
2const path = require('path');

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 3–4why, one step back
3const { test, describe } = require('node:test');
4const assert = require('node:assert/strict');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 5–11why, one step back
5
6// Test details of the exitOverride errors.7// The important checks are the exitCode and code which are intended to be stable for8// semver minor versions. For now, also testing the error.message and that output occurred9// to detect accidental changes in behaviour.1011function expectCommanderError(err, exitCode, code, message) {

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 12–15why, one step back
12 assert(err instanceof commander.CommanderError);
13 assert.equal(err.exitCode, exitCode);14 assert.equal(err.code, code);15 assert.equal(err.message, message);

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 16–17why, one step back
16}
17

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

line 18why, one step back
18describe('Command.exitOverride', () => {

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 19–20why, one step back
19 // Use internal knowledge to suppress output to keep test output clean.
20

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 21–22why, one step back
21 test('when specify unknown program option then throw CommanderError', (t) => {
22 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 23why, one step back
23 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 24why, one step back
24 program.exitOverride();

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 25–32why, one step back
25
26 let caughtErr;27 try {28 program.parse(['node', 'test', '-m']);29 } catch (err) {30 caughtErr = err;31 }32

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 33why, one step back
33 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 34–39why, one step back
34 expectCommanderError(
35 caughtErr,36 1,37 'commander.unknownOption',38 "error: unknown option '-m'",39 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 40–41why, one step back
40 });
41

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 42–43why, one step back
42 test('when specify unknown command then throw CommanderError', (t) => {
43 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 44why, one step back
44 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 45why, one step back
45 program.name('prog').exitOverride().command('sub');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 46–53why, one step back
46
47 let caughtErr;48 try {49 program.parse(['node', 'test', 'oops']);50 } catch (err) {51 caughtErr = err;52 }53

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 54why, one step back
54 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 55–60why, one step back
55 expectCommanderError(
56 caughtErr,57 1,58 'commander.unknownCommand',59 "error: unknown command 'oops'",60 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 61–63why, one step back
61 });
6263 // Same error as above, but with custom handler.

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 64–65why, one step back
64 test('when supply custom handler then throw custom error', (t) => {
65 t.mock.method(process.stderr, 'write', () => {});

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 66–70why, one step back
66 const customError = new commander.CommanderError(
67 123,68 'custom-code',69 'custom-message',70 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 71why, one step back
71 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 72–74why, one step back
72 program.exitOverride((_err) => {
73 throw customError;74 });

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 75–82why, one step back
75
76 let caughtErr;77 try {78 program.parse(['node', 'test', '-m']);79 } catch (err) {80 caughtErr = err;81 }82

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 83–88why, one step back
83 expectCommanderError(
84 caughtErr,85 customError.exitCode,86 customError.code,87 customError.message,88 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 89–90why, one step back
89 });
90

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 91–92why, one step back
91 test('when specify option without required value then throw CommanderError', (t) => {
92 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 93–94why, one step back
93 const optionFlags = '-p, --pepper <type>';
94 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 95why, one step back
95 program.exitOverride().option(optionFlags, 'add pepper');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 96–103why, one step back
96
97 let caughtErr;98 try {99 program.parse(['node', 'test', '--pepper']);100 } catch (err) {101 caughtErr = err;102 }103

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 104why, one step back
104 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 105–110why, one step back
105 expectCommanderError(
106 caughtErr,107 1,108 'commander.optionMissingArgument',109 `error: option '${optionFlags}' argument missing`,110 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 111–112why, one step back
111 });
112

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 113–114why, one step back
113 test('when specify command without required argument then throw CommanderError', (t) => {
114 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 115–118why, one step back
115 const program = new commander.Command();
116 program117 .exitOverride()118 .command('compress <arg-name>')

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 119why, one step back
119 .action(() => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 120–127why, one step back
120
121 let caughtErr;122 try {123 program.parse(['node', 'test', 'compress']);124 } catch (err) {125 caughtErr = err;126 }127

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 128why, one step back
128 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 129–134why, one step back
129 expectCommanderError(
130 caughtErr,131 1,132 'commander.missingArgument',133 "error: missing required argument 'arg-name'",134 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 135–136why, one step back
135 });
136

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 137–138why, one step back
137 test('when specify program without required argument and no action handler then throw CommanderError', (t) => {
138 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 139why, one step back
139 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 140why, one step back
140 program.exitOverride().argument('<arg-name>');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 141–148why, one step back
141
142 let caughtErr;143 try {144 program.parse(['node', 'test']);145 } catch (err) {146 caughtErr = err;147 }148

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 149why, one step back
149 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 150–155why, one step back
150 expectCommanderError(
151 caughtErr,152 1,153 'commander.missingArgument',154 "error: missing required argument 'arg-name'",155 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 156–157why, one step back
156 });
157

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 158–159why, one step back
158 test('when specify excess argument then throw CommanderError', (t) => {
159 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 160–163why, one step back
160 const program = new commander.Command();
161 program162 .exitOverride()163 .allowExcessArguments(false)

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 164why, one step back
164 .action(() => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 165–172why, one step back
165
166 let caughtErr;167 try {168 program.parse(['node', 'test', 'excess']);169 } catch (err) {170 caughtErr = err;171 }172

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 173why, one step back
173 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 174–177why, one step back
174 expectCommanderError(
175 caughtErr,176 1,177 'commander.excessArguments',

List excess arguments in error message (#2384)stiffbefore adoption2e96cd3

line 178why, one step back
178 'error: too many arguments. Expected 0 arguments but got 1: excess.',

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 179why, one step back
179 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 180–181why, one step back
180 });
181

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 182–183why, one step back
182 test('when specify command with excess argument then throw CommanderError', (t) => {
183 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 184–188why, one step back
184 const program = new commander.Command();
185 program186 .exitOverride()187 .command('speak')188 .allowExcessArguments(false)

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 189why, one step back
189 .action(() => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 190–197why, one step back
190
191 let caughtErr;192 try {193 program.parse(['node', 'test', 'speak', 'excess']);194 } catch (err) {195 caughtErr = err;196 }197

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 198why, one step back
198 assert(stderrSpy.mock.callCount() > 0);

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 199–202why, one step back
199 expectCommanderError(
200 caughtErr,201 1,202 'commander.excessArguments',

List excess arguments in error message (#2384)stiffbefore adoption2e96cd3

line 203why, one step back
203 "error: too many arguments for 'speak'. Expected 0 arguments but got 1: excess.",

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 204why, one step back
204 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 205–206why, one step back
205 });
206

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 207–208why, one step back
207 test('when specify --help then throw CommanderError', (t) => {
208 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 209why, one step back
209 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 210why, one step back
210 program.exitOverride();

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 211–218why, one step back
211
212 let caughtErr;213 try {214 program.parse(['node', 'test', '--help']);215 } catch (err) {216 caughtErr = err;217 }218

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 219–224why, one step back
219 expectCommanderError(
220 caughtErr,221 0,222 'commander.helpDisplayed',223 '(outputHelp)',224 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 225–226why, one step back
225 });
226

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 227–228why, one step back
227 test('when executable subcommand and no command specified then throw CommanderError', (t) => {
228 const stderrSpy = t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 229why, one step back
229 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 230why, one step back
230 program.exitOverride().command('compress', 'compress description');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 231–241why, one step back
231
232 let caughtErr;233 try {234 program.parse(['node', 'test']);235 } catch (err) {236 caughtErr = err;237 }238239 expectCommanderError(caughtErr, 1, 'commander.help', '(outputHelp)');240 });241

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 242–243why, one step back
242 test('when specify --version then throw CommanderError', (t) => {
243 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 244–245why, one step back
244 const myVersion = '1.2.3';
245 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 246why, one step back
246 program.exitOverride().version(myVersion);

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 247–257why, one step back
247
248 let caughtErr;249 try {250 program.parse(['node', 'test', '--version']);251 } catch (err) {252 caughtErr = err;253 }254255 expectCommanderError(caughtErr, 0, 'commander.version', myVersion);256 });257

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 258why, one step back
258 test('when executableSubcommand succeeds then call exitOverride', async () => {

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 259–263why, one step back
259 const pm = path.join(__dirname, 'fixtures/pm');
260 const program = new commander.Command();261 await new Promise((resolve) => {262 program263 .exitOverride((err) => {

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 264–269why, one step back
264 expectCommanderError(
265 err,266 0,267 'commander.executeSubCommandAsync',268 '(close)',269 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 270–276why, one step back
270 resolve();
271 })272 .command('silent', 'description');273 program.parse(['node', pm, 'silent']);274 });275 });276

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 277–278why, one step back
277 test('when mandatory program option missing then throw CommanderError', (t) => {
278 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 279–280why, one step back
279 const optionFlags = '-p, --pepper <type>';
280 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 281why, one step back
281 program.exitOverride().requiredOption(optionFlags, 'add pepper');

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 282–289why, one step back
282
283 let caughtErr;284 try {285 program.parse(['node', 'test']);286 } catch (err) {287 caughtErr = err;288 }289

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 290–295why, one step back
290 expectCommanderError(
291 caughtErr,292 1,293 'commander.missingMandatoryOptionValue',294 `error: required option '${optionFlags}' not specified`,295 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 296–297why, one step back
296 });
297

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 298–299why, one step back
298 test('when option argument not in choices then throw CommanderError', (t) => {
299 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 300–312why, one step back
300 const optionFlags = '--colour <shade>';
301 const program = new commander.Command();302 program303 .exitOverride()304 .addOption(new commander.Option(optionFlags).choices(['red', 'blue']));305306 let caughtErr;307 try {308 program.parse(['--colour', 'green'], { from: 'user' });309 } catch (err) {310 caughtErr = err;311 }312

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 313–318why, one step back
313 expectCommanderError(
314 caughtErr,315 1,316 'commander.invalidArgument',317 "error: option '--colour <shade>' argument 'green' is invalid. Allowed choices are red, blue.",318 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 319–320why, one step back
319 });
320

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 321–322why, one step back
321 test('when command argument not in choices then throw CommanderError', (t) => {
322 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 323–335why, one step back
323 const program = new commander.Command();
324 program325 .exitOverride()326 .addArgument(new commander.Argument('<shade>').choices(['red', 'blue']))327 .action(() => {});328329 let caughtErr;330 try {331 program.parse(['green'], { from: 'user' });332 } catch (err) {333 caughtErr = err;334 }335

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 336–341why, one step back
336 expectCommanderError(
337 caughtErr,338 1,339 'commander.invalidArgument',340 "error: command-argument value 'green' is invalid for argument 'shade'. Allowed choices are red, blue.",341 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 342–343why, one step back
342 });
343

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 344–345why, one step back
344 test('when custom processing for option throws InvalidArgumentError then catch CommanderError', (t) => {
345 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 346–350why, one step back
346 function justSayNo(value) {
347 throw new commander.InvalidArgumentError('NO');348 }349 const optionFlags = '--colour <shade>';350 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 351why, one step back
351 program.exitOverride().option(optionFlags, 'specify shade', justSayNo);

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 352–359why, one step back
352
353 let caughtErr;354 try {355 program.parse(['--colour', 'green'], { from: 'user' });356 } catch (err) {357 caughtErr = err;358 }359

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 360–365why, one step back
360 expectCommanderError(
361 caughtErr,362 1,363 'commander.invalidArgument',364 "error: option '--colour <shade>' argument 'green' is invalid. NO",365 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 366–367why, one step back
366 });
367

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 368–369why, one step back
368 test('when custom processing for argument throws InvalidArgumentError then catch CommanderError', (t) => {
369 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 370–385why, one step back
370 function justSayNo(value) {
371 throw new commander.InvalidArgumentError('NO');372 }373 const program = new commander.Command();374 program375 .exitOverride()376 .argument('[n]', 'number', justSayNo)377 .action(() => {});378379 let caughtErr;380 try {381 program.parse(['green'], { from: 'user' });382 } catch (err) {383 caughtErr = err;384 }385

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 386–391why, one step back
386 expectCommanderError(
387 caughtErr,388 1,389 'commander.invalidArgument',390 "error: command-argument value 'green' is invalid for argument 'n'. NO",391 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 392–393why, one step back
392 });
393

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 394–395why, one step back
394 test('when has conflicting option then throw CommanderError', (t) => {
395 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 396–408why, one step back
396 const program = new commander.Command();
397 program398 .exitOverride()399 .addOption(new commander.Option('--silent'))400 .addOption(new commander.Option('--debug').conflicts(['silent']));401402 let caughtErr;403 try {404 program.parse(['--debug', '--silent'], { from: 'user' });405 } catch (err) {406 caughtErr = err;407 }408

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 409–414why, one step back
409 expectCommanderError(
410 caughtErr,411 1,412 'commander.conflictingOption',413 "error: option '--debug' cannot be used with option '--silent'",414 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 415–416why, one step back
415 });
416

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 417–418why, one step back
417 test('when call error() then throw CommanderError', (t) => {
418 t.mock.method(process.stderr, 'write', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 419why, one step back
419 const program = new commander.Command();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

line 420why, one step back
420 program.exitOverride();

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 421–432why, one step back
421
422 let caughtErr;423 try {424 program.error('message');425 } catch (err) {426 caughtErr = err;427 }428429 expectCommanderError(caughtErr, 1, 'commander.error', 'message');430 });431});432

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 433–434why, one step back
433test('when no override and error then exit(1)', (t) => {
434 const exitSpy = t.mock.method(process, 'exit', () => {});

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 435–437why, one step back
435 const program = new commander.Command();
436 program.configureOutput({ outputError: () => {} });437 program.parse(['--unknownOption'], { from: 'user' });

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 438–439why, one step back
438 assert(exitSpy.mock.callCount() >= 1);
439 assert.deepEqual(exitSpy.mock.calls[0].arguments, [1]);

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

lines 440–450why, one step back
440});
441442test('when custom processing throws custom error then throw custom error', () => {443 function justSayNo(value) {444 throw new Error('custom');445 }446 const program = new commander.Command();447 program448 .exitOverride()449 .option('-s, --shade <value>', 'specify shade', justSayNo);450

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 451–456why, one step back
451 assert.throws(
452 () => {453 program.parse(['--shade', 'green'], { from: 'user' });454 },455 { message: 'custom' },456 );

Add string[] to options defaultValue type (#1721)Caleb Everettbefore adoption1b492d9

line 457why, one step back
457});