Switch from Jest to Node.js built-in test runner (#2463)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent 63eed4a · Browse files · 118 files·+3560 added−6622 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
118 files+3560 added−6622 removed
- tests:+3550 added−3480 removed
- other:+10 added−3142 removed
Provenance
- Commit
3dd6086- Tree
bebc7db- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
63eed4a
118 files changed+3560 added−6622 removed
modified:tests/args.literal.test.js+6 added-4 removed
12345677 unmodified lines15161718171819192021222324252627282930293132const commander = require('../');const { test } = require('node:test');const assert = require('node:assert/strict');
// Utility Conventions: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02//// 12.2 Utility Syntax Guidelines, Guideline 10:7 unmodified lines .argument('[args...]'); program.parse(['node', 'test', '--foo', '--', '--bar', 'baz']); // More than one assert, ported from legacy test const opts = program.opts(); expect(opts.foo).toBe(true); expect(opts.bar).toBeUndefined(); expect(program.args).toEqual(['--bar', 'baz']); assert.equal(opts.foo, true); assert.equal(opts.bar, undefined); assert.deepEqual(program.args, ['--bar', 'baz']);});
test('when arguments include -- then more literals are passed-through as args', () => { const program = new commander.Command(); program .option('-f, --foo', 'add some foo') .option('-b, --bar', 'add some bar') .argument('[args...]'); program.parse(['node', 'test', '--', 'cmd', '--', '--arg']); expect(program.args).toEqual(['cmd', '--', '--arg']); assert.deepEqual(program.args, ['cmd', '--', '--arg']);});modified:tests/args.variadic.test.js+26 added-23 removed
1234356767891011121314131516171819161720212223242526272425262728292829303132323333343536373839394041424342434445464748495051505253545556575856596058616263646566646768666970717273747573767778const commander = require('../');const { test, describe } = require('node:test');const assert = require('node:assert/strict');
// Testing variadic arguments. Testing all the action arguments, but could test just variadicArg.// Testing variadic arguments.
describe('variadic argument', () => { test('when no extra arguments specified for program then variadic arg is empty array', () => { const actionMock = jest.fn(); test('when no extra arguments specified for program then variadic arg is empty array', (t) => { const actionMock = t.mock.fn(); const program = new commander.Command(); program.arguments('<id> [variadicArg...]').action(actionMock);
program.parse(['node', 'test', 'id']);
expect(actionMock).toHaveBeenCalledWith('id', [], program.opts(), program); const callArgs = actionMock.mock.calls[0].arguments; assert.equal(callArgs[0], 'id'); assert.deepEqual(callArgs[1], []); });
test('when extra arguments specified for program then variadic arg is array of values', () => { const actionMock = jest.fn(); test('when extra arguments specified for program then variadic arg is array of values', (t) => { const actionMock = t.mock.fn(); const program = new commander.Command(); program.arguments('<id> [variadicArg...]').action(actionMock); const extraArguments = ['a', 'b', 'c'];
program.parse(['node', 'test', 'id', ...extraArguments]);
expect(actionMock).toHaveBeenCalledWith( 'id', extraArguments, program.opts(), program, ); const callArgs = actionMock.mock.calls[0].arguments; assert.equal(callArgs[0], 'id'); assert.deepEqual(callArgs[1], extraArguments); });
test('when no extra arguments specified for command then variadic arg is empty array', () => { const actionMock = jest.fn(); test('when no extra arguments specified for command then variadic arg is empty array', (t) => { const actionMock = t.mock.fn(); const program = new commander.Command(); const cmd = program.command('sub [variadicArg...]').action(actionMock);
program.parse(['node', 'test', 'sub']);
expect(actionMock).toHaveBeenCalledWith([], cmd.opts(), cmd); const callArgs = actionMock.mock.calls[0].arguments; assert.deepEqual(callArgs[0], []); });
test('when extra arguments specified for command then variadic arg is array of values', () => { const actionMock = jest.fn(); test('when extra arguments specified for command then variadic arg is array of values', (t) => { const actionMock = t.mock.fn(); const program = new commander.Command(); const cmd = program.command('sub [variadicArg...]').action(actionMock); const extraArguments = ['a', 'b', 'c'];
program.parse(['node', 'test', 'sub', ...extraArguments]);
expect(actionMock).toHaveBeenCalledWith(extraArguments, cmd.opts(), cmd); const callArgs = actionMock.mock.calls[0].arguments; assert.deepEqual(callArgs[0], extraArguments); });
test('when program variadic argument not last then error', () => { const program = new commander.Command();
expect(() => { assert.throws(() => { program.arguments('<variadicArg...> [optionalArg]'); }).toThrow("only the last argument can be variadic 'variadicArg'"); }, /only the last argument can be variadic 'variadicArg'/); });
test('when command variadic argument not last then error', () => { const program = new commander.Command();
expect(() => { assert.throws(() => { program.command('sub <variadicArg...> [optionalArg]'); }).toThrow("only the last argument can be variadic 'variadicArg'"); }, /only the last argument can be variadic 'variadicArg'/); });
test('when variadic argument then usage shows variadic', () => { const program = new commander.Command(); program.name('foo').arguments('[args...]');
expect(program.usage()).toBe('[options] [args...]'); assert.equal(program.usage(), '[options] [args...]'); });});modified:tests/argument.chain.test.js+7 added-5 removed
1234567879101112131413151617181920192122232425262527282930313231333435const { Argument } = require('../');const { test, describe } = require('node:test');const assert = require('node:assert/strict');
describe('Argument methods that should return this for chaining', () => { test('when call .default() then returns this', () => { const argument = new Argument('<value>'); const result = argument.default(3); expect(result).toBe(argument); assert.equal(result, argument); });
test('when call .argParser() then returns this', () => { const argument = new Argument('<value>'); const result = argument.argParser(() => {}); expect(result).toBe(argument); assert.equal(result, argument); });
test('when call .choices() then returns this', () => { const argument = new Argument('<value>'); const result = argument.choices(['a']); expect(result).toBe(argument); assert.equal(result, argument); });
test('when call .argRequired() then returns this', () => { const argument = new Argument('<value>'); const result = argument.argRequired(); expect(result).toBe(argument); assert.equal(result, argument); });
test('when call .argOptional() then returns this', () => { const argument = new Argument('<value>'); const result = argument.argOptional(); expect(result).toBe(argument); assert.equal(result, argument); });});modified:tests/argument.choices.test.js+17 added-23 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 test('when command argument in choices then argument set', () => {4- const program = new commander.Command();7+ const program = createTestCommand();8 let shade;9 program7- .exitOverride()10 .addArgument(new commander.Argument('<shade>').choices(['red', 'blue']))11 .action((shadeParam) => {12 shade = shadeParam;13 });14 program.parse(['red'], { from: 'user' });13- expect(shade).toBe('red');15+ assert.equal(shade, 'red');16 });17 18 test('when command argument is not in choices then error', () => {19 // Lightweight check, more detailed testing of behaviour in command.exitOverride.test.js18- const program = new commander.Command();19- program20- .exitOverride()21- .configureOutput({22- writeErr: () => {},23- })24- .addArgument(new commander.Argument('<shade>').choices(['red', 'blue']));25- expect(() => {20+ const program = createTestCommand();21+ program.addArgument(22+ new commander.Argument('<shade>').choices(['red', 'blue']),23+ );24+ assert.throws(() => {25 program.parse(['orange'], { from: 'user' });27- }).toThrow();26+ });27 });28 29 describe('choices parameter is treated as readonly, per TypeScript declaration', () => {30 test('when choices called then parameter does not change', () => {31 // Unlikely this could break, but check the API we are declaring in TypeScript.32 const original = ['red', 'blue', 'green'];33 const param = original.slice();34 new commander.Argument('<shade>').choices(param);36- expect(param).toEqual(original);35+ assert.deepEqual(param, original);36 });37 38 test('when choices called and argChoices later changed then parameter does not change', () => {39 const original = ['red', 'blue', 'green'];40 const param = original.slice();41 const argument = new commander.Argument('<shade>').choices(param);42 argument.argChoices.push('purple');44- expect(param).toEqual(original);43+ assert.deepEqual(param, original);44 });45 46 test('when choices called and parameter changed the choices does not change', () => {48- const program = new commander.Command();47+ const program = createTestCommand();48 const param = ['red', 'blue'];50- program51- .exitOverride()52- .configureOutput({53- writeErr: () => {},54- })55- .addArgument(new commander.Argument('<shade>').choices(param));49+ program.addArgument(new commander.Argument('<shade>').choices(param));50 param.push('orange');57- expect(() => {51+ assert.throws(() => {52 program.parse(['orange'], { from: 'user' });59- }).toThrow();53+ });54 });55 });modified:tests/argument.custom-processing.test.js+52 added-48 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test } = require('node:test');4+const assert = require('node:assert/strict');5 6 // Testing default value and custom processing behaviours.7 // Some double assertions in tests to check action argument and .processedArg8 6-test('when argument not specified then callback not called', () => {7- const mockCoercion = jest.fn();9+test('when argument not specified then callback not called', (t) => {10+ const mockCoercion = t.mock.fn();11 const program = new commander.Command();12 program.argument('[n]', 'number', mockCoercion).action(() => {});13 program.parse([], { from: 'user' });11- expect(mockCoercion).not.toHaveBeenCalled();14+ assert.equal(mockCoercion.mock.callCount(), 0);15 });16 17 test('when argument not specified then action argument undefined', () => {18 let actionValue = 'foo';1 unmodified line20 program.argument('[n]', 'number', parseFloat).action((arg) => {21 actionValue = arg;22 });23 program.parse([], { from: 'user' });21- expect(actionValue).toBeUndefined();24+ assert.equal(actionValue, undefined);25 });26 24-test('when custom with starting value and argument not specified then callback not called', () => {25- const mockCoercion = jest.fn();27+test('when custom with starting value and argument not specified then callback not called', (t) => {28+ const mockCoercion = t.mock.fn();29 const program = new commander.Command();30 program.argument('[n]', 'number', parseFloat, 1).action(() => {});31 program.parse([], { from: 'user' });29- expect(mockCoercion).not.toHaveBeenCalled();32+ assert.equal(mockCoercion.mock.callCount(), 0);33 });34 35 test('when custom with starting value and argument not specified with action handler then action argument is starting value', () => {36 const startingValue = 1;2 unmodified lines39 program.argument('[n]', 'number', parseFloat, startingValue).action((arg) => {40 actionValue = arg;41 });42 program.parse([], { from: 'user' });40- expect(actionValue).toEqual(startingValue);41- expect(program.processedArgs).toEqual([startingValue]);43+ assert.equal(actionValue, startingValue);44+ assert.deepEqual(program.processedArgs, [startingValue]);45 });46 47 test('when custom with starting value and argument not specified without action handler then .processedArgs has starting value', () => {48 const startingValue = 1;49 const program = new commander.Command();50 program.argument('[n]', 'number', parseFloat, startingValue);51 program.parse([], { from: 'user' });49- expect(program.processedArgs).toEqual([startingValue]);52+ assert.deepEqual(program.processedArgs, [startingValue]);53 });54 55 test('when default value is defined (without custom processing) and argument not specified with action handler then action argument is default value', () => {56 const defaultValue = 1;2 unmodified lines59 program.argument('[n]', 'number', defaultValue).action((arg) => {60 actionValue = arg;61 });62 program.parse([], { from: 'user' });60- expect(actionValue).toEqual(defaultValue);61- expect(program.processedArgs).toEqual([defaultValue]);63+ assert.equal(actionValue, defaultValue);64+ assert.deepEqual(program.processedArgs, [defaultValue]);65 });66 67 test('when default value is defined (without custom processing) and argument not specified without action handler then .processedArgs is default value', () => {68 const defaultValue = 1;69 const program = new commander.Command();70 program.argument('[n]', 'number', defaultValue);71 program.parse([], { from: 'user' });69- expect(program.processedArgs).toEqual([defaultValue]);72+ assert.deepEqual(program.processedArgs, [defaultValue]);73 });74 72-test('when argument specified then callback called with value', () => {73- const mockCoercion = jest.fn();75+test('when argument specified then callback called with value', (t) => {76+ const mockCoercion = t.mock.fn();77 const value = '1';78 const program = new commander.Command();79 program.argument('[n]', 'number', mockCoercion).action(() => {});80 program.parse([value], { from: 'user' });78- expect(mockCoercion).toHaveBeenCalledWith(value, undefined);81+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, [value, undefined]);82 });83 84 test('when argument specified with action handler then action value is as returned from callback', () => {85 const callbackResult = 2;6 unmodified lines92 .action((arg) => {93 actionValue = arg;94 });95 program.parse(['node', 'test', 'alpha']);93- expect(actionValue).toEqual(callbackResult);94- expect(program.processedArgs).toEqual([callbackResult]);96+ assert.equal(actionValue, callbackResult);97+ assert.deepEqual(program.processedArgs, [callbackResult]);98 });99 100 test('when argument specified without action handler then .processedArgs is as returned from callback', () => {101 const callbackResult = 2;1 unmodified line103 program.argument('[n]', 'number', () => {104 return callbackResult;105 });106 program.parse(['node', 'test', 'alpha']);104- expect(program.processedArgs).toEqual([callbackResult]);107+ assert.deepEqual(program.processedArgs, [callbackResult]);108 });109 110 test('when argument specified then program.args has original rather than custom', () => {111 // This is as intended, so check behaviour.4 unmodified lines116 return callbackResult;117 })118 .action(() => {});119 program.parse(['node', 'test', 'alpha']);117- expect(program.args).toEqual(['alpha']);120+ assert.deepEqual(program.args, ['alpha']);121 });122 120-test('when custom with starting value and argument specified then callback called with value and starting value', () => {121- const mockCoercion = jest.fn();123+test('when custom with starting value and argument specified then callback called with value and starting value', (t) => {124+ const mockCoercion = t.mock.fn();125 const startingValue = 1;126 const value = '2';127 const program = new commander.Command()128 .argument('[n]', 'number', mockCoercion, startingValue)129 .action(() => {});130 program.parse(['node', 'test', value]);128- expect(mockCoercion).toHaveBeenCalledWith(value, startingValue);131+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, [132+ value,133+ startingValue,134+ ]);135 });136 131-test('when variadic argument specified multiple times then callback called with value and previousValue', () => {132- const mockCoercion = jest.fn().mockImplementation(() => {137+test('when variadic argument specified multiple times then callback called with value and previousValue', (t) => {138+ const mockCoercion = t.mock.fn(() => {139 return 'callback';140 });141 const program = new commander.Command();142 program.argument('<n...>', 'number', mockCoercion).action(() => {});143 program.parse(['1', '2'], { from: 'user' });138- expect(mockCoercion).toHaveBeenCalledTimes(2);139- expect(mockCoercion).toHaveBeenNthCalledWith(1, '1', undefined);140- expect(mockCoercion).toHaveBeenNthCalledWith(2, '2', 'callback');144+ assert.equal(mockCoercion.mock.callCount(), 2);145+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, ['1', undefined]);146+ assert.deepEqual(mockCoercion.mock.calls[1].arguments, ['2', 'callback']);147 });148 149 test('when variadic argument without action handler then .processedArg has array', () => {150 const program = new commander.Command();151 program.argument('<n...>', 'number');152 program.parse(['1', '2'], { from: 'user' });147- expect(program.processedArgs).toEqual([['1', '2']]);153+ assert.deepEqual(program.processedArgs, [['1', '2']]);154 });155 156 test('when parseFloat "1e2" then action argument is 100', () => {157 let actionValue;1 unmodified line159 program.argument('<number>', 'float argument', parseFloat).action((arg) => {160 actionValue = arg;161 });162 program.parse(['1e2'], { from: 'user' });157- expect(actionValue).toEqual(100);158- expect(program.processedArgs).toEqual([actionValue]);163+ assert.equal(actionValue, 100);164+ assert.deepEqual(program.processedArgs, [actionValue]);165 });166 167 test('when defined default value for required argument then throw', () => {168 const program = new commander.Command();163- expect(() => {169+ assert.throws(() => {170 program.argument('<number>', 'float argument', 4);165- }).toThrow();171+ });172 });173 174 test('when custom processing for argument throws plain error then not CommanderError caught', () => {175 function justSayNo(value) {170- throw new Error('no no no');176+ throw new Error('plain error');177 }172- const program = new commander.Command();173- program174- .exitOverride()175- .argument('[n]', 'number', justSayNo)176- .action(() => {});178+ const program = createTestCommand();179+ program.argument('[n]', 'number', justSayNo).action(() => {});180 178- let caughtErr;179- try {180- program.parse(['green'], { from: 'user' });181- } catch (err) {182- caughtErr = err;183- }184-185- expect(caughtErr).toBeInstanceOf(Error);186- expect(caughtErr).not.toBeInstanceOf(commander.CommanderError);181+ assert.throws(182+ () => {183+ program.parse(['green'], { from: 'user' });184+ },185+ (err) => {186+ assert.equal(err instanceof Error, true);187+ assert.equal(err instanceof commander.CommanderError, false);188+ return true;189+ },190+ );191 });modified:tests/argument.required.test.js+7 added-5 removed
123456789810111213141315161718192019212223242526272628293031323334333536const commander = require('../');const { test } = require('node:test');const assert = require('node:assert/strict');
// Low-level tests of setting Argument.required.// Higher level tests of optional/required arguments elsewhere.
test('when name with surrounding <> then argument required', () => { const argument = new commander.Argument('<name>'); expect(argument.required).toBe(true); assert.equal(argument.required, true);});
test('when name with surrounding [] then argument optional', () => { const argument = new commander.Argument('[name]'); expect(argument.required).toBe(false); assert.equal(argument.required, false);});
test('when name without surrounding brackets then argument required', () => { // default behaviour, allowed from Commander 8 const argument = new commander.Argument('name'); expect(argument.required).toBe(true); assert.equal(argument.required, true);});
test('when call .argRequired() then argument required', () => { const argument = new commander.Argument('name'); argument.required = false; argument.argRequired(); expect(argument.required).toBe(true); assert.equal(argument.required, true);});
test('when call .argOptional() then argument optional', () => { const argument = new commander.Argument('name'); argument.required = true; argument.argOptional(); expect(argument.required).toBe(false); assert.equal(argument.required, false);});modified:tests/argument.variadic.test.js+28 added-25 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Testing variadic arguments. Testing all the action arguments, but could test just variadicArg.6 5-describe('variadic argument', () => {6- test('when no extra arguments specified for program then variadic arg is empty array', () => {7- const actionMock = jest.fn();7+describe('variadic argument', (t) => {8+ test('when no extra arguments specified for program then variadic arg is empty array', (t) => {9+ const actionMock = t.mock.fn();10 const program = new commander.Command();11 program.argument('<id>').argument('[variadicArg...]').action(actionMock);12 13 program.parse(['node', 'test', 'id']);14 13- expect(actionMock).toHaveBeenCalledWith('id', [], program.opts(), program);15+ const callArgs = actionMock.mock.calls[0].arguments;16+ assert.equal(callArgs[0], 'id');17+ assert.deepEqual(callArgs[1], []);18 });19 16- test('when extra arguments specified for program then variadic arg is array of values', () => {17- const actionMock = jest.fn();20+ test('when extra arguments specified for program then variadic arg is array of values', (t) => {21+ const actionMock = t.mock.fn();22 const program = new commander.Command();23 program24 .addArgument(new commander.Argument('<id>'))25 .argument('[variadicArg...]')1 unmodified line27 const extraArguments = ['a', 'b', 'c'];28 29 program.parse(['node', 'test', 'id', ...extraArguments]);30 27- expect(actionMock).toHaveBeenCalledWith(28- 'id',29- extraArguments,30- program.opts(),31- program,32- );31+ const callArgs = actionMock.mock.calls[0].arguments;32+ assert.equal(callArgs[0], 'id');33+ assert.deepEqual(callArgs[1], extraArguments);34 });35 35- test('when no extra arguments specified for command then variadic arg is empty array', () => {36- const actionMock = jest.fn();36+ test('when no extra arguments specified for command then variadic arg is empty array', (t) => {37+ const actionMock = t.mock.fn();38 const program = new commander.Command();39 const cmd = program.command('sub [variadicArg...]').action(actionMock);40 41 program.parse(['node', 'test', 'sub']);42 42- expect(actionMock).toHaveBeenCalledWith([], cmd.opts(), cmd);43+ const callArgs = actionMock.mock.calls[0].arguments;44+ assert.deepEqual(callArgs[0], []);45 });46 45- test('when extra arguments specified for command then variadic arg is array of values', () => {46- const actionMock = jest.fn();47+ test('when extra arguments specified for command then variadic arg is array of values', (t) => {48+ const actionMock = t.mock.fn();49 const program = new commander.Command();50 const cmd = program.command('sub [variadicArg...]').action(actionMock);51 const extraArguments = ['a', 'b', 'c'];52 53 program.parse(['node', 'test', 'sub', ...extraArguments]);54 53- expect(actionMock).toHaveBeenCalledWith(extraArguments, cmd.opts(), cmd);55+ const callArgs = actionMock.mock.calls[0].arguments;56+ assert.deepEqual(callArgs[0], extraArguments);57 });58 59 test('when program variadic argument not last then error', () => {60 const program = new commander.Command();61 59- expect(() => {62+ assert.throws(() => {63 program.argument('<variadicArg...>').argument('[optionalArg]');61- }).toThrow("only the last argument can be variadic 'variadicArg'");64+ }, /only the last argument can be variadic 'variadicArg'/);65 });66 67 test('when command variadic argument not last then error', () => {68 const program = new commander.Command();69 67- expect(() => {70+ assert.throws(() => {71 program.command('sub <variadicArg...> [optionalArg]');69- }).toThrow("only the last argument can be variadic 'variadicArg'");72+ }, /only the last argument can be variadic 'variadicArg'/);73 });74 75 test('when variadic argument then usage shows variadic', () => {76 const program = new commander.Command();77 program.name('foo').argument('[args...]');78 76- expect(program.usage()).toBe('[options] [args...]');79+ assert.equal(program.usage(), '[options] [args...]');80 });81 82 test('when variadic used with choices and one value then set in array', () => {83 const program = new commander.Command();4 unmodified lines88 passedArg = value;89 });90 91 program.parse(['one'], { from: 'user' });89- expect(passedArg).toEqual(['one']);92+ assert.deepEqual(passedArg, ['one']);93 });94 95 test('when variadic used with choices and two values then set in array', () => {96 const program = new commander.Command();4 unmodified lines101 passedArg = value;102 });103 104 program.parse(['one', 'two'], { from: 'user' });102- expect(passedArg).toEqual(['one', 'two']);105+ assert.deepEqual(passedArg, ['one', 'two']);106 });107 });modified:tests/command.action.test.js+99 added-74 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // Test some behaviours of .action not covered in more specific tests.7 5-test('when .action called then command passed to action', () => {6- const actionMock = jest.fn();8+test('when .action called then command passed to action', (t) => {9+ const actionMock = t.mock.fn();10 const program = new commander.Command();11 const cmd = program.command('info').action(actionMock);12 program.parse(['node', 'test', 'info']);10- expect(actionMock).toHaveBeenCalledWith(cmd.opts(), cmd);13+ const callArgs = actionMock.mock.calls[0].arguments;14+ assert.equal(callArgs[0], cmd.opts());15+ assert.equal(callArgs[1], cmd);16 });17 18 test('when .action called then this is set to command', () => {19 const program = new commander.Command();1 unmodified line21 const cmd = program.command('info').action(function () {22 actionThis = this;23 });24 program.parse(['node', 'test', 'info']);20- expect(actionThis).toBe(cmd);25+ assert.equal(actionThis, cmd);26 });27 28 test('when .action called then program.args only contains args', () => {29 // At one time program.args was being modified to contain the same args as the call to .action30 // and so included the command as an extra and unexpected complex item in array.31 const program = new commander.Command();32 program.command('info <file>').action(() => {});33 program.parse(['node', 'test', 'info', 'my-file']);29- expect(program.args).toEqual(['info', 'my-file']);34+ assert.deepEqual(program.args, ['info', 'my-file']);35 });36 32-test.each(getTestCases('<file>'))(33- 'when .action on program with required argument via %s and argument supplied then action called',34- (methodName, program) => {35- const actionMock = jest.fn();36- program.action(actionMock);37- program.parse(['node', 'test', 'my-file']);38- expect(actionMock).toHaveBeenCalledWith('my-file', program.opts(), program);39- },40-);37+describe('when .action on program with required argument and argument supplied then action called', () => {38+ getTestCases('<file>').forEach(([methodName, program]) => {39+ test(`via ${methodName}`, (t) => {40+ const actionMock = t.mock.fn();41+ program.action(actionMock);42+ program.parse(['node', 'test', 'my-file']);43+ const callArgs = actionMock.mock.calls[0].arguments;44+ assert.equal(callArgs[0], 'my-file');45+ assert.equal(callArgs[1], program.opts());46+ assert.equal(callArgs[2], program);47+ });48+ });49+});50 42-test.each(getTestCases('<file>'))(43- 'when .action on program with required argument via %s and argument not supplied then action not called',44- (methodName, program) => {45- const actionMock = jest.fn();46- program47- .exitOverride()48- .configureOutput({ writeErr: () => {} })49- .action(actionMock);50- expect(() => {51- program.parse(['node', 'test']);52- }).toThrow();53- expect(actionMock).not.toHaveBeenCalled();54- },55-);51+describe('when .action on program with required argument and argument not supplied then action not called', () => {52+ getTestCases('<file>').forEach(([methodName, program]) => {53+ test(`via ${methodName}`, (t) => {54+ const actionMock = t.mock.fn();55+ program.action(actionMock);56+ assert.throws(() => {57+ program.parse(['node', 'test']);58+ });59+ assert.equal(actionMock.mock.callCount(), 0);60+ });61+ });62+});63 64 // Changes made in #729 to call program action handler58-test('when .action on program and no arguments then action called', () => {59- const actionMock = jest.fn();65+test('when .action on program and no arguments then action called', (t) => {66+ const actionMock = t.mock.fn();67 const program = new commander.Command();68 program.action(actionMock);69 program.parse(['node', 'test']);63- expect(actionMock).toHaveBeenCalledWith(program.opts(), program);70+ const callArgs = actionMock.mock.calls[0].arguments;71+ assert.equal(callArgs[0], program.opts());72+ assert.equal(callArgs[1], program);73 });74 66-test.each(getTestCases('[file]'))(67- 'when .action on program with optional argument via %s supplied then action called',68- (methodName, program) => {69- const actionMock = jest.fn();70- program.action(actionMock);71- program.parse(['node', 'test', 'my-file']);72- expect(actionMock).toHaveBeenCalledWith('my-file', program.opts(), program);73- },74-);75+describe('when .action on program with optional argument supplied then action called', () => {76+ getTestCases('[file]').forEach(([methodName, program]) => {77+ test(`via ${methodName}`, (t) => {78+ const actionMock = t.mock.fn();79+ program.action(actionMock);80+ program.parse(['node', 'test', 'my-file']);81+ const callArgs = actionMock.mock.calls[0].arguments;82+ assert.equal(callArgs[0], 'my-file');83+ assert.equal(callArgs[1], program.opts());84+ assert.equal(callArgs[2], program);85+ });86+ });87+});88 76-test.each(getTestCases('[file]'))(77- 'when .action on program without optional argument supplied then action called',78- (methodName, program) => {79- const actionMock = jest.fn();80- program.action(actionMock);81- program.parse(['node', 'test']);82- expect(actionMock).toHaveBeenCalledWith(undefined, program.opts(), program);83- },84-);89+describe('when .action on program without optional argument supplied then action called', () => {90+ getTestCases('[file]').forEach(([methodName, program]) => {91+ test(`via ${methodName}`, (t) => {92+ const actionMock = t.mock.fn();93+ program.action(actionMock);94+ program.parse(['node', 'test']);95+ const callArgs = actionMock.mock.calls[0].arguments;96+ assert.equal(callArgs[0], undefined);97+ assert.equal(callArgs[1], program.opts());98+ assert.equal(callArgs[2], program);99+ });100+ });101+});102 86-test.each(getTestCases('[file]'))(87- 'when .action on program with optional argument via %s and subcommand and program argument then program action called',88- (methodName, program) => {89- const actionMock = jest.fn();90- program.action(actionMock);91- program.command('subcommand');103+describe('when .action on program with optional argument and subcommand and program argument then program action called', () => {104+ getTestCases('[file]').forEach(([methodName, program]) => {105+ test(`via ${methodName}`, (t) => {106+ const actionMock = t.mock.fn();107+ program.action(actionMock);108+ program.command('subcommand');109 93- program.parse(['node', 'test', 'a']);110+ program.parse(['node', 'test', 'a']);111 95- expect(actionMock).toHaveBeenCalledWith('a', program.opts(), program);96- },97-);112+ const callArgs = actionMock.mock.calls[0].arguments;113+ assert.equal(callArgs[0], 'a');114+ assert.equal(callArgs[1], program.opts());115+ assert.equal(callArgs[2], program);116+ });117+ });118+});119 120 // Changes made in #1062 to allow this case100-test.each(getTestCases('[file]'))(101- 'when .action on program with optional argument via %s and subcommand and no program argument then program action called',102- (methodName, program) => {103- const actionMock = jest.fn();104- program.action(actionMock);105- program.command('subcommand');121+describe('when .action on program with optional argument and subcommand and no program argument then program action called', () => {122+ getTestCases('[file]').forEach(([methodName, program]) => {123+ test(`via ${methodName}`, (t) => {124+ const actionMock = t.mock.fn();125+ program.action(actionMock);126+ program.command('subcommand');127 107- program.parse(['node', 'test']);128+ program.parse(['node', 'test']);129 109- expect(actionMock).toHaveBeenCalledWith(undefined, program.opts(), program);110- },111-);130+ const callArgs = actionMock.mock.calls[0].arguments;131+ assert.equal(callArgs[0], undefined);132+ assert.equal(callArgs[1], program.opts());133+ assert.equal(callArgs[2], program);134+ });135+ });136+});137 138 test('when action is async then can await parseAsync', async () => {139 let asyncFinished = false;140 async function delay() {3 unmodified lines144 const program = new commander.Command();145 program.action(delay);146 147 const later = program.parseAsync(['node', 'test']);123- expect(asyncFinished).toBe(false);148+ assert.equal(asyncFinished, false);149 await later;125- expect(asyncFinished).toBe(true);150+ assert.equal(asyncFinished, true);151 });152 153 function getTestCases(arg) {129- const withArguments = new commander.Command().arguments(arg);130- const withArgument = new commander.Command().argument(arg);131- const withAddArgument = new commander.Command().addArgument(154+ const withArguments = createTestCommand().arguments(arg);155+ const withArgument = createTestCommand().argument(arg);156+ const withAddArgument = createTestCommand().addArgument(157 new commander.Argument(arg),158 );159 return [160 ['.arguments', withArguments],4 unmodified linesmodified:tests/command.addCommand.test.js+12 added-11 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // simple sanity check subcommand works4-test('when addCommand and specify subcommand then called', () => {6+test('when addCommand and specify subcommand then called', (t) => {7 const program = new commander.Command();6- const leafAction = jest.fn();8+ const leafAction = t.mock.fn();9 const sub = new commander.Command();10 sub.name('sub').action(leafAction);11 program.addCommand(sub);12 13 program.parse('node test.js sub'.split(' '));12- expect(leafAction).toHaveBeenCalled();14+ assert.equal(leafAction.mock.callCount(), 1);15 });16 17 test('when commands added using .addCommand and .command then internals similar', () => {18 const program1 = new commander.Command();5 unmodified lines24 // since .command() is well tested and understood.25 26 const cmd1 = program1.commands[0];27 const cmd2 = program2.commands[0];26- expect(cmd1.parent).toBe(program1);27- expect(cmd2.parent).toBe(program2);28+ assert.equal(cmd1.parent, program1);29+ assert.equal(cmd2.parent, program2);30 31 for (const key of Object.keys(cmd1)) {32 switch (typeof cmd1[key]) {33 case 'string':34 case 'boolean':35 case 'number':36 case 'undefined':37 // Compare values in a way that will be readable in test failure message.36- // eslint-disable-next-line jest/no-conditional-expect37- expect(`${key}:${cmd1[key]}`).toEqual(`${key}:${cmd2[key]}`);38+ assert.equal(`${key}:${cmd1[key]}`, `${key}:${cmd2[key]}`);39 break;40 }41 }42 });43 44 test('when command without name passed to .addCommand then throw', () => {45 const program = new commander.Command();46 const cmd = new commander.Command();46- expect(() => {47+ assert.throws(() => {48 program.addCommand(cmd);48- }).toThrow();49+ });50 });51 52 test('when executable command with custom executableFile passed to .addCommand then ok', () => {53 const program = new commander.Command();54 const cmd = new commander.Command('sub');55 cmd.command('exec', 'exec description', { executableFile: 'custom' });55- expect(() => {56+ assert.doesNotThrow(() => {57 program.addCommand(cmd);57- }).not.toThrow();58+ });59 });modified:tests/command.addHelpOption.test.js+22 added-34 removed
1-const { Command, Option } = require('../');1+const { Option } = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // More complete tests are in command.helpOption.test.js.7 8 describe('addHelpOption', () => {6- let writeSpy;7- let writeErrorSpy;8-9- beforeAll(() => {10- // Optional. Suppress expected output to keep test output clean.11- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});12- writeErrorSpy = jest13- .spyOn(process.stderr, 'write')14- .mockImplementation(() => {});15- });16-17- afterEach(() => {18- writeSpy.mockClear();19- writeErrorSpy.mockClear();20- });21-22- afterAll(() => {23- writeSpy.mockRestore();24- writeErrorSpy.mockRestore();25- });26-9 test('when addHelpOption has custom flags then custom short flag invokes help', () => {28- const program = new Command();29- program.exitOverride().addHelpOption(new Option('-c,--custom-help'));10+ const program = createTestCommand();11+ program.addHelpOption(new Option('-c,--custom-help'));12 31- expect(() => {32- program.parse(['-c'], { from: 'user' });33- }).toThrow('(outputHelp)');13+ assert.throws(14+ () => {15+ program.parse(['-c'], { from: 'user' });16+ },17+ { message: '(outputHelp)' },18+ );19 });20 21 test('when addHelpOption has custom flags then custom long flag invokes help', () => {37- const program = new Command();38- program.exitOverride().addHelpOption(new Option('-c,--custom-help'));22+ const program = createTestCommand();23+ program.addHelpOption(new Option('-c,--custom-help'));24 40- expect(() => {41- program.parse(['--custom-help'], { from: 'user' });42- }).toThrow('(outputHelp)');25+ assert.throws(26+ () => {27+ program.parse(['--custom-help'], { from: 'user' });28+ },29+ { message: '(outputHelp)' },30+ );31 });32 33 test('when addHelpOption with hidden help option then help does not include help option', () => {46- const program = new Command();34+ const program = createTestCommand();35 program.addHelpOption(36 new Option('-c,--custom-help', 'help help help').hideHelp(),37 );38 const helpInfo = program.helpInformation();51- expect(helpInfo).not.toMatch(/help/);39+ assert.doesNotMatch(helpInfo, /help/);40 });41 });modified:tests/command.addHelpText.test.js+81 added-88 removed
1 const commander = require('../');2+const { test, describe, beforeEach } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Using outputHelp to simplify testing.6 7 describe('program calls to addHelpText', () => {8 let writeSpy;9 8- beforeAll(() => {9- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});10+ beforeEach((t) => {11+ writeSpy = t.mock.method(process.stdout, 'write', () => {});12 });13 12- afterEach(() => {13- writeSpy.mockClear();14- });15-16- afterAll(() => {17- writeSpy.mockRestore();18- });19-14 test('when "before" string then string before built-in help', () => {15 const program = new commander.Command();16 program.addHelpText('before', 'text');17 program.outputHelp();24- expect(writeSpy).toHaveBeenNthCalledWith(1, 'text\n');25- expect(writeSpy).toHaveBeenNthCalledWith(2, program.helpInformation());18+ assert.equal(writeSpy.mock.calls[0].arguments[0], 'text\n');19+ assert.equal(20+ writeSpy.mock.calls[1].arguments[0],21+ program.helpInformation(),22+ );23 });24 25 test('when "before" function then function result before built-in help', () => {26 const program = new commander.Command();27 program.addHelpText('before', () => 'text');28 program.outputHelp();32- expect(writeSpy).toHaveBeenNthCalledWith(1, 'text\n');33- expect(writeSpy).toHaveBeenNthCalledWith(2, program.helpInformation());29+ assert.equal(writeSpy.mock.calls[0].arguments[0], 'text\n');30+ assert.equal(31+ writeSpy.mock.calls[1].arguments[0],32+ program.helpInformation(),33+ );34 });35 36 test('when "before" function returns nothing then no effect', () => {37 const program = new commander.Command();38 program.addHelpText('before', () => {});39 program.outputHelp();40- expect(writeSpy).toHaveBeenNthCalledWith(1, program.helpInformation());40+ assert.equal(41+ writeSpy.mock.calls[0].arguments[0],42+ program.helpInformation(),43+ );44 });45 46 test('when "beforeAll" string then string before built-in help', () => {47 const program = new commander.Command();48 program.addHelpText('beforeAll', 'text');49 program.outputHelp();47- expect(writeSpy).toHaveBeenNthCalledWith(1, 'text\n');48- expect(writeSpy).toHaveBeenNthCalledWith(2, program.helpInformation());50+ assert.equal(writeSpy.mock.calls[0].arguments[0], 'text\n');51+ assert.equal(52+ writeSpy.mock.calls[1].arguments[0],53+ program.helpInformation(),54+ );55 });56 57 test('when "after" string then string after built-in help', () => {58 const program = new commander.Command();59 program.addHelpText('after', 'text');60 program.outputHelp();55- expect(writeSpy).toHaveBeenNthCalledWith(1, program.helpInformation());56- expect(writeSpy).toHaveBeenNthCalledWith(2, 'text\n');61+ assert.equal(62+ writeSpy.mock.calls[0].arguments[0],63+ program.helpInformation(),64+ );65+ assert.equal(writeSpy.mock.calls[1].arguments[0], 'text\n');66 });67 68 test('when "afterAll" string then string after built-in help', () => {69 const program = new commander.Command();70 program.addHelpText('afterAll', 'text');71 program.outputHelp();63- expect(writeSpy).toHaveBeenNthCalledWith(1, program.helpInformation());64- expect(writeSpy).toHaveBeenNthCalledWith(2, 'text\n');72+ assert.equal(73+ writeSpy.mock.calls[0].arguments[0],74+ program.helpInformation(),75+ );76+ assert.equal(writeSpy.mock.calls[1].arguments[0], 'text\n');77 });78 79 test('when all the simple positions then strings in order', () => {80 const program = new commander.Command();1 unmodified line82 program.addHelpText('after', 'after');83 program.addHelpText('beforeAll', 'beforeAll');84 program.addHelpText('afterAll', 'afterAll');85 program.outputHelp();74- expect(writeSpy).toHaveBeenNthCalledWith(1, 'beforeAll\n');75- expect(writeSpy).toHaveBeenNthCalledWith(2, 'before\n');76- expect(writeSpy).toHaveBeenNthCalledWith(3, program.helpInformation());77- expect(writeSpy).toHaveBeenNthCalledWith(4, 'after\n');78- expect(writeSpy).toHaveBeenNthCalledWith(5, 'afterAll\n');86+ assert.equal(writeSpy.mock.calls[0].arguments[0], 'beforeAll\n');87+ assert.equal(writeSpy.mock.calls[1].arguments[0], 'before\n');88+ assert.equal(89+ writeSpy.mock.calls[2].arguments[0],90+ program.helpInformation(),91+ );92+ assert.equal(writeSpy.mock.calls[3].arguments[0], 'after\n');93+ assert.equal(writeSpy.mock.calls[4].arguments[0], 'afterAll\n');94 });95 96 test('when "silly" position then throw', () => {97 const program = new commander.Command();83- expect(() => {98+ assert.throws(() => {99 program.addHelpText('silly', 'text');85- }).toThrow();100+ });101 });102 });103 104 describe('program and subcommand calls to addHelpText', () => {105 let writeSpy;106 92- beforeAll(() => {93- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});107+ beforeEach((t) => {108+ writeSpy = t.mock.method(process.stdout, 'write', () => {});109 });110 96- afterEach(() => {97- writeSpy.mockClear();98- });99-100- afterAll(() => {101- writeSpy.mockRestore();102- });103-104- test('when "before" on program then not called on subcommand', () => {111+ test('when "before" on program then not called on subcommand', (t) => {112 const program = new commander.Command();113 const sub = program.command('sub');107- const testMock = jest.fn();114+ const testMock = t.mock.fn();115 program.addHelpText('before', testMock);116 sub.outputHelp();110- expect(testMock).not.toHaveBeenCalled();117+ assert.equal(testMock.mock.callCount(), 0);118 });119 113- test('when "beforeAll" on program then is called on subcommand', () => {120+ test('when "beforeAll" on program then is called on subcommand', (t) => {121 const program = new commander.Command();122 const sub = program.command('sub');116- const testMock = jest.fn();123+ const testMock = t.mock.fn();124 program.addHelpText('beforeAll', testMock);125 sub.outputHelp();119- expect(testMock).toHaveBeenCalled();126+ assert.equal(testMock.mock.callCount(), 1);127 });128 122- test('when "after" on program then not called on subcommand', () => {129+ test('when "after" on program then not called on subcommand', (t) => {130 const program = new commander.Command();131 const sub = program.command('sub');125- const testMock = jest.fn();132+ const testMock = t.mock.fn();133 program.addHelpText('after', testMock);134 sub.outputHelp();128- expect(testMock).not.toHaveBeenCalled();135+ assert.equal(testMock.mock.callCount(), 0);136 });137 131- test('when "afterAll" on program then is called on subcommand', () => {138+ test('when "afterAll" on program then is called on subcommand', (t) => {139 const program = new commander.Command();140 const sub = program.command('sub');134- const testMock = jest.fn();141+ const testMock = t.mock.fn();142 program.addHelpText('afterAll', testMock);143 sub.outputHelp();137- expect(testMock).toHaveBeenCalled();144+ assert.equal(testMock.mock.callCount(), 1);145 });146 });147 148 describe('context checks with full parse', () => {149 let stdoutSpy;150 let stderrSpy;151 145- beforeAll(() => {146- stdoutSpy = jest147- .spyOn(process.stdout, 'write')148- .mockImplementation(() => {});149- stderrSpy = jest150- .spyOn(process.stderr, 'write')151- .mockImplementation(() => {});152+ beforeEach((t) => {153+ stdoutSpy = t.mock.method(process.stdout, 'write', () => {});154+ stderrSpy = t.mock.method(process.stderr, 'write', () => {});155 });156 154- afterEach(() => {155- stdoutSpy.mockClear();156- stderrSpy.mockClear();157- });158-159- afterAll(() => {160- stdoutSpy.mockRestore();161- stderrSpy.mockRestore();162- });163-157 test('when help requested then text is on stdout', () => {158 const program = new commander.Command();159 program.exitOverride().addHelpText('before', 'text');167- expect(() => {160+ assert.throws(() => {161 program.parse(['--help'], { from: 'user' });169- }).toThrow();170- expect(stdoutSpy).toHaveBeenCalledWith('text\n');162+ });163+ assert.equal(stdoutSpy.mock.calls[0].arguments[0], 'text\n');164 });165 166 test('when help for error then text is on stderr', () => {167 const program = new commander.Command();168 program.exitOverride().addHelpText('before', 'text').command('sub');176- expect(() => {169+ assert.throws(() => {170 program.parse([], { from: 'user' });178- }).toThrow();179- expect(stderrSpy).toHaveBeenCalledWith('text\n');171+ });172+ assert.equal(stderrSpy.mock.calls[0].arguments[0], 'text\n');173 });174 175 test('when help requested then context.error is false', () => {176 let context;177 const program = new commander.Command();178 program.exitOverride().addHelpText('before', (contextParam) => {179 context = contextParam;180 });188- expect(() => {181+ assert.throws(() => {182 program.parse(['--help'], { from: 'user' });190- }).toThrow();191- expect(context.error).toBe(false);183+ });184+ assert.equal(context.error, false);185 });186 187 test('when help for error then context.error is true', () => {188 let context;3 unmodified lines192 .addHelpText('before', (contextParam) => {193 context = contextParam;194 })195 .command('sub');203- expect(() => {196+ assert.throws(() => {197 program.parse([], { from: 'user' });205- }).toThrow();206- expect(context.error).toBe(true);198+ });199+ assert.equal(context.error, true);200 });201 202 test('when help on program then context.command is program', () => {203 let context;204 const program = new commander.Command();205 program.exitOverride().addHelpText('before', (contextParam) => {206 context = contextParam;207 });215- expect(() => {208+ assert.throws(() => {209 program.parse(['--help'], { from: 'user' });217- }).toThrow();218- expect(context.command).toBe(program);210+ });211+ assert.equal(context.command, program);212 });213 214 test('when help on subcommand and "before" subcommand then context.command is subcommand', () => {215 let context;1 unmodified line217 program.exitOverride();218 const sub = program.command('sub').addHelpText('before', (contextParam) => {219 context = contextParam;220 });228- expect(() => {221+ assert.throws(() => {222 program.parse(['sub', '--help'], { from: 'user' });230- }).toThrow();231- expect(context.command).toBe(sub);223+ });224+ assert.equal(context.command, sub);225 });226 227 test('when help on subcommand and "beforeAll" on program then context.command is subcommand', () => {228 let context;1 unmodified line230 program.exitOverride().addHelpText('beforeAll', (contextParam) => {231 context = contextParam;232 });233 const sub = program.command('sub');241- expect(() => {234+ assert.throws(() => {235 program.parse(['sub', '--help'], { from: 'user' });243- }).toThrow();244- expect(context.command).toBe(sub);236+ });237+ assert.equal(context.command, sub);238 });239 });modified:tests/command.alias.test.js+26 added-21 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Running alias commands is tested in command.executableSubcommand.lookup.test.js6 // Test various other behaviours for .alias7 8 test('when command has alias then appears in help', () => {9 const program = new commander.Command();10 program.command('info [thing]').alias('i');11 const helpInformation = program.helpInformation();10- expect(helpInformation).toMatch('info|i');12+ assert.match(helpInformation, /info\|i/);13 });14 15 test('when command has aliases added separately then only first appears in help', () => {16 const program = new commander.Command();17 program.command('list [thing]').alias('ls').alias('dir');18 const helpInformation = program.helpInformation();17- expect(helpInformation).toMatch('list|ls ');19+ assert.match(helpInformation, /list\|ls /);20 });21 22 test('when command has aliases then only first appears in help', () => {23 const program = new commander.Command();24 program.command('list [thing]').aliases(['ls', 'dir']);25 const helpInformation = program.helpInformation();24- expect(helpInformation).toMatch('list|ls ');26+ assert.match(helpInformation, /list\|ls /);27 });28 29 test('when command name = alias then error', () => {30 const program = new commander.Command();29- expect(() => {30- program.command('fail').alias('fail');31- }).toThrow("Command alias can't be the same as its name");31+ assert.throws(32+ () => {33+ program.command('fail').alias('fail');34+ },35+ { message: "Command alias can't be the same as its name" },36+ );37 });38 34-test('when use alias then action handler called', () => {39+test('when use alias then action handler called', (t) => {40 const program = new commander.Command();36- const actionMock = jest.fn();41+ const actionMock = t.mock.fn();42 program.command('list').alias('ls').action(actionMock);43 program.parse(['ls'], { from: 'user' });39- expect(actionMock).toHaveBeenCalled();44+ assert.equal(actionMock.mock.callCount(), 1);45 });46 42-test('when use second alias added separately then action handler called', () => {47+test('when use second alias added separately then action handler called', (t) => {48 const program = new commander.Command();44- const actionMock = jest.fn();49+ const actionMock = t.mock.fn();50 program.command('list').alias('ls').alias('dir').action(actionMock);51 program.parse(['dir'], { from: 'user' });47- expect(actionMock).toHaveBeenCalled();52+ assert.equal(actionMock.mock.callCount(), 1);53 });54 50-test('when use second of aliases then action handler called', () => {55+test('when use second of aliases then action handler called', (t) => {56 const program = new commander.Command();52- const actionMock = jest.fn();57+ const actionMock = t.mock.fn();58 program.command('list').aliases(['ls', 'dir']).action(actionMock);59 program.parse(['dir'], { from: 'user' });55- expect(actionMock).toHaveBeenCalled();60+ assert.equal(actionMock.mock.callCount(), 1);61 });62 63 test('when set alias then can get alias', () => {64 const program = new commander.Command();65 const alias = 'abcde';66 program.alias(alias);62- expect(program.alias()).toEqual(alias);67+ assert.equal(program.alias(), alias);68 });69 70 test('when set aliases then can get aliases', () => {71 const program = new commander.Command();72 const aliases = ['a', 'b'];73 program.aliases(aliases);69- expect(program.aliases()).toEqual(aliases);74+ assert.deepEqual(program.aliases(), aliases);75 });76 77 test('when set alias on executable then can get alias', () => {78 const program = new commander.Command();79 const alias = 'abcde';80 program.command('external', 'external command').alias(alias);76- expect(program.commands[0].alias()).toEqual(alias);81+ assert.equal(program.commands[0].alias(), alias);82 });83 84 describe('aliases parameter is treated as readonly, per TypeScript declaration', () => {85 test('when aliases called then parameter does not change', () => {86 // Unlikely this could break, but check the API we are declaring in TypeScript.87 const original = ['b', 'bld'];88 const param = original.slice();89 new commander.Command('build').aliases(param);85- expect(param).toEqual(original);90+ assert.deepEqual(param, original);91 });92 93 test('when aliases called and aliases later changed then parameter does not change', () => {94 const original = ['b', 'bld'];95 const param = original.slice();96 const cmd = new commander.Command('build').aliases(param);97 cmd.alias('BBB');93- expect(param).toEqual(original);98+ assert.deepEqual(param, original);99 });100 101 test('when aliases called and parameter later changed then aliases does not change', () => {102 const original = ['b', 'bld'];103 const param = original.slice();104 const cmd = new commander.Command('build').aliases(param);105 param.length = 0;101- expect(cmd.aliases()).toEqual(original);106+ assert.deepEqual(cmd.aliases(), original);107 });108 });modified:tests/command.allowExcessArguments.test.js+90 added-91 removed
1-const commander = require('../');1+const { createTestCommand } = require('./testHelpers');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Not testing output, just testing whether an error is detected.6 5-describe.each([true, false])(6- 'allowExcessArguments when action handler: %s',7- (hasActionHandler) => {8- function configureCommand(cmd) {9- cmd.exitOverride().configureOutput({10- writeErr: () => {},11- });12- if (hasActionHandler) {13- cmd.action(() => {});7+describe('allowExcessArguments', () => {8+ const cases = [true, false];9+ cases.forEach((hasActionHandler) => {10+ describe(`when ${hasActionHandler ? 'has' : 'no'} action handler`, () => {11+ function configureCommand(cmd) {12+ if (hasActionHandler) cmd.action(() => {});13 }15- }14 17- test('when specify excess program argument then error by default', () => {18- const program = new commander.Command();19- configureCommand(program);15+ test('when specify excess program argument then error by default', () => {16+ const program = createTestCommand();17+ configureCommand(program);18 21- expect(() => {22- program.parse(['excess'], { from: 'user' });23- }).toThrow();24- });19+ assert.throws(() => {20+ program.parse(['excess'], { from: 'user' });21+ });22+ });23 26- test('when specify excess program argument and allowExcessArguments(false) then error', () => {27- const program = new commander.Command();28- configureCommand(program);29- program.allowExcessArguments(false);24+ test('when specify excess program argument and allowExcessArguments(false) then error', () => {25+ const program = createTestCommand();26+ configureCommand(program);27+ program.allowExcessArguments(false);28 31- expect(() => {32- program.parse(['excess'], { from: 'user' });33- }).toThrow();34- });29+ assert.throws(() => {30+ program.parse(['excess'], { from: 'user' });31+ });32+ });33 36- test('when specify excess program argument and allowExcessArguments() then no error', () => {37- const program = new commander.Command();38- configureCommand(program);39- program.allowExcessArguments();34+ test('when specify excess program argument and allowExcessArguments() then no error', () => {35+ const program = createTestCommand();36+ configureCommand(program);37+ program.allowExcessArguments();38 41- expect(() => {42- program.parse(['excess'], { from: 'user' });43- }).not.toThrow();44- });39+ assert.doesNotThrow(() => {40+ program.parse(['excess'], { from: 'user' });41+ });42+ });43 46- test('when specify excess program argument and allowExcessArguments(true) then no error', () => {47- const program = new commander.Command();48- configureCommand(program);49- program.allowExcessArguments(true);44+ test('when specify excess program argument and allowExcessArguments(true) then no error', () => {45+ const program = createTestCommand();46+ configureCommand(program);47+ program.allowExcessArguments(true);48 51- expect(() => {52- program.parse(['excess'], { from: 'user' });53- }).not.toThrow();54- });49+ assert.doesNotThrow(() => {50+ program.parse(['excess'], { from: 'user' });51+ });52+ });53 56- test('when specify excess command argument then error (by default)', () => {57- const program = new commander.Command();58- const sub = program.command('sub');59- configureCommand(sub);54+ test('when specify excess command argument then error (by default)', () => {55+ const program = createTestCommand();56+ const sub = program.command('sub');57+ configureCommand(sub);58 61- expect(() => {62- program.parse(['sub', 'excess'], { from: 'user' });63- }).toThrow();64- });59+ assert.throws(() => {60+ program.parse(['sub', 'excess'], { from: 'user' });61+ });62+ });63 66- test('when specify excess command argument and allowExcessArguments(false) then error', () => {67- const program = new commander.Command();68- const sub = program.command('sub').allowExcessArguments(false);69- configureCommand(sub);64+ test('when specify excess command argument and allowExcessArguments(false) then error', () => {65+ const program = createTestCommand();66+ const sub = program.command('sub').allowExcessArguments(false);67+ configureCommand(sub);68 71- expect(() => {72- program.parse(['sub', 'excess'], { from: 'user' });73- }).toThrow();74- });69+ assert.throws(() => {70+ program.parse(['sub', 'excess'], { from: 'user' });71+ });72+ });73 76- test('when specify expected arg and allowExcessArguments(false) then no error', () => {77- const program = new commander.Command();78- configureCommand(program);79- program.argument('<file>').allowExcessArguments(false);74+ test('when specify expected arg and allowExcessArguments(false) then no error', () => {75+ const program = createTestCommand();76+ configureCommand(program);77+ program.argument('<file>').allowExcessArguments(false);78 81- expect(() => {82- program.parse(['file'], { from: 'user' });83- }).not.toThrow();84- });79+ assert.doesNotThrow(() => {80+ program.parse(['file'], { from: 'user' });81+ });82+ });83 86- test('when specify excess after <arg> and allowExcessArguments(false) then error', () => {87- const program = new commander.Command();88- configureCommand(program);89- program.argument('<file>').allowExcessArguments(false);84+ test('when specify excess after <arg> and allowExcessArguments(false) then error', () => {85+ const program = createTestCommand();86+ configureCommand(program);87+ program.argument('<file>').allowExcessArguments(false);88 91- expect(() => {92- program.parse(['file', 'excess'], { from: 'user' });93- }).toThrow();94- });89+ assert.throws(() => {90+ program.parse(['file', 'excess'], { from: 'user' });91+ });92+ });93 96- test('when specify excess after [arg] and allowExcessArguments(false) then error', () => {97- const program = new commander.Command();98- configureCommand(program);99- program.argument('[file]').allowExcessArguments(false);94+ test('when specify excess after [arg] and allowExcessArguments(false) then error', () => {95+ const program = createTestCommand();96+ configureCommand(program);97+ program.argument('[file]').allowExcessArguments(false);98 101- expect(() => {102- program.parse(['file', 'excess'], { from: 'user' });103- }).toThrow();104- });99+ assert.throws(() => {100+ program.parse(['file', 'excess'], { from: 'user' });101+ });102+ });103 106- test('when specify args for [args...] and allowExcessArguments(false) then no error', () => {107- const program = new commander.Command();108- configureCommand(program);109- program.argument('[files...]').allowExcessArguments(false);104+ test('when specify args for [args...] and allowExcessArguments(false) then no error', () => {105+ const program = createTestCommand();106+ configureCommand(program);107+ program.argument('[files...]').allowExcessArguments(false);108 111- expect(() => {112- program.parse(['file1', 'file2', 'file3'], { from: 'user' });113- }).not.toThrow();109+ assert.doesNotThrow(() => {110+ program.parse(['file1', 'file2', 'file3'], { from: 'user' });111+ });112+ });113 });115- },116-);114+ });115+});modified:tests/command.allowUnknownOption.test.js+27 added-45 removed
1-const commander = require('../');1+const { createTestCommand } = require('./testHelpers');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Not testing output, just testing whether an error is detected.6 7 describe('allowUnknownOption', () => {6- // Optional. Use internal knowledge to suppress output to keep test output clean.7- let writeErrorSpy;8-9- beforeAll(() => {10- writeErrorSpy = jest11- .spyOn(process.stderr, 'write')12- .mockImplementation(() => {});13- });14-15- afterEach(() => {16- writeErrorSpy.mockClear();17- });18-19- afterAll(() => {20- writeErrorSpy.mockRestore();21- });22-8 test('when specify unknown program option then error', () => {24- const program = new commander.Command();25- program.exitOverride().option('-p, --pepper', 'add pepper');9+ const program = createTestCommand();10+ program.option('-p, --pepper', 'add pepper');11 27- expect(() => {12+ assert.throws(() => {13 program.parse(['node', 'test', '-m']);29- }).toThrow();14+ });15 });16 17 test('when specify unknown program option and allowUnknownOption(false) then error', () => {33- const program = new commander.Command();34- program35- .exitOverride()36- .allowUnknownOption(false)37- .option('-p, --pepper', 'add pepper');18+ const program = createTestCommand();19+ program.allowUnknownOption(false).option('-p, --pepper', 'add pepper');20 39- expect(() => {21+ assert.throws(() => {22 program.parse(['node', 'test', '-m']);41- }).toThrow();23+ });24 });25 26 test('when specify unknown program option and allowUnknownOption() then no error', () => {45- const program = new commander.Command();27+ const program = createTestCommand();28 program47- .exitOverride()29+30 .allowUnknownOption()31 .argument('[args...]') // unknown option will be passed as an argument32 .option('-p, --pepper', 'add pepper');33 52- expect(() => {34+ assert.doesNotThrow(() => {35 program.parse(['node', 'test', '-m']);54- }).not.toThrow();36+ });37 });38 39 test('when specify unknown program option and allowUnknownOption(true) then no error', () => {58- const program = new commander.Command();40+ const program = createTestCommand();41 program60- .exitOverride()42+43 .allowUnknownOption(true)44 .argument('[args...]') // unknown option will be passed as an argument45 .option('-p, --pepper', 'add pepper');46 65- expect(() => {47+ assert.doesNotThrow(() => {48 program.parse(['node', 'test', '-m']);67- }).not.toThrow();49+ });50 });51 52 test('when specify unknown command option then error', () => {71- const program = new commander.Command();53+ const program = createTestCommand();54 program73- .exitOverride()55+56 .command('sub')57 .option('-p, --pepper', 'add pepper')58 .action(() => {});59 78- expect(() => {60+ assert.throws(() => {61 program.parse(['node', 'test', 'sub', '-m']);80- }).toThrow();62+ });63 });64 65 test('when specify unknown command option and allowUnknownOption then no error', () => {84- const program = new commander.Command();66+ const program = createTestCommand();67 program86- .exitOverride()68+69 .command('sub')70 .argument('[args...]') // unknown option will be passed as an argument71 .allowUnknownOption()72 .option('-p, --pepper', 'add pepper')73 .action(() => {});74 93- expect(() => {75+ assert.doesNotThrow(() => {76 program.parse(['node', 'test', 'sub', '-m']);95- }).not.toThrow();77+ });78 });79 });modified:tests/command.argumentVariations.test.js+77 added-86 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Do some low-level checks that the multiple ways of specifying command arguments produce same internal result,6 // and not exhaustively testing all methods elsewhere.7 6-test.each(getSingleArgCases('<explicit-required>'))(7- 'when add "<arg>" using %s then argument required',8- (methodName, cmd) => {9- const argument = cmd.registeredArguments[0];10- const expectedShape = {11- _name: 'explicit-required',12- required: true,13- variadic: false,14- description: '',15- };16- expect(argument).toEqual(expectedShape);17- },18-);8+describe('when add "<arg>" then argument required', () => {9+ getSingleArgCases('<explicit-required>').forEach(([methodName, cmd]) => {10+ test(`using ${methodName}`, () => {11+ const argument = cmd.registeredArguments[0];12+ assert.equal(argument._name, 'explicit-required');13+ assert.equal(argument.required, true);14+ assert.equal(argument.variadic, false);15+ assert.equal(argument.description, '');16+ });17+ });18+});19 20-test.each(getSingleArgCases('implicit-required'))(21- 'when add "arg" using %s then argument required',22- (methodName, cmd) => {23- const argument = cmd.registeredArguments[0];24- const expectedShape = {25- _name: 'implicit-required',26- required: true,27- variadic: false,28- description: '',29- };30- expect(argument).toEqual(expectedShape);31- },32-);20+describe('when add "arg" then argument required', () => {21+ getSingleArgCases('implicit-required').forEach(([methodName, cmd]) => {22+ test(`using ${methodName}`, () => {23+ const argument = cmd.registeredArguments[0];24+ assert.equal(argument._name, 'implicit-required');25+ assert.equal(argument.required, true);26+ assert.equal(argument.variadic, false);27+ assert.equal(argument.description, '');28+ });29+ });30+});31 34-test.each(getSingleArgCases('[optional]'))(35- 'when add "[arg]" using %s then argument optional',36- (methodName, cmd) => {37- const argument = cmd.registeredArguments[0];38- const expectedShape = {39- _name: 'optional',40- required: false,41- variadic: false,42- description: '',43- };44- expect(argument).toEqual(expectedShape);45- },46-);32+describe('when add "[arg]" then argument optional', () => {33+ getSingleArgCases('[optional]').forEach(([methodName, cmd]) => {34+ test(`using ${methodName}`, () => {35+ const argument = cmd.registeredArguments[0];36+ assert.equal(argument._name, 'optional');37+ assert.equal(argument.required, false);38+ assert.equal(argument.variadic, false);39+ assert.equal(argument.description, '');40+ });41+ });42+});43 48-test.each(getSingleArgCases('<explicit-required...>'))(49- 'when add "<arg...>" using %s then argument required and variadic',50- (methodName, cmd) => {51- const argument = cmd.registeredArguments[0];52- const expectedShape = {53- _name: 'explicit-required',54- required: true,55- variadic: true,56- description: '',57- };58- expect(argument).toEqual(expectedShape);59- },60-);44+describe('when add "<arg...>" then argument required and variadic', () => {45+ getSingleArgCases('<explicit-required...>').forEach(([methodName, cmd]) => {46+ test(`using ${methodName}`, () => {47+ const argument = cmd.registeredArguments[0];48+ assert.equal(argument._name, 'explicit-required');49+ assert.equal(argument.required, true);50+ assert.equal(argument.variadic, true);51+ assert.equal(argument.description, '');52+ });53+ });54+});55 62-test.each(getSingleArgCases('implicit-required...'))(63- 'when add "arg..." using %s then argument required and variadic',64- (methodName, cmd) => {65- const argument = cmd.registeredArguments[0];66- const expectedShape = {67- _name: 'implicit-required',68- required: true,69- variadic: true,70- description: '',71- };72- expect(argument).toEqual(expectedShape);73- },74-);56+describe('when add "arg..." then argument required and variadic', () => {57+ getSingleArgCases('implicit-required...').forEach(([methodName, cmd]) => {58+ test(`using ${methodName}`, () => {59+ const argument = cmd.registeredArguments[0];60+ assert.equal(argument._name, 'implicit-required');61+ assert.equal(argument.required, true);62+ assert.equal(argument.variadic, true);63+ assert.equal(argument.description, '');64+ });65+ });66+});67 76-test.each(getSingleArgCases('[optional...]'))(77- 'when add "[arg...]" using %s then argument optional and variadic',78- (methodName, cmd) => {79- const argument = cmd.registeredArguments[0];80- const expectedShape = {81- _name: 'optional',82- required: false,83- variadic: true,84- description: '',85- };86- expect(argument).toEqual(expectedShape);87- },88-);68+describe('when add "[arg...]" then argument optional and variadic', () => {69+ getSingleArgCases('[optional...]').forEach(([methodName, cmd]) => {70+ test(`using ${methodName}`, () => {71+ const argument = cmd.registeredArguments[0];72+ assert.equal(argument._name, 'optional');73+ assert.equal(argument.required, false);74+ assert.equal(argument.variadic, true);75+ assert.equal(argument.description, '');76+ });77+ });78+});79 80 function getSingleArgCases(arg) {81 return [82 ['.arguments', new commander.Command().arguments(arg)],7 unmodified lines90 ['.command', new commander.Command().command(`command ${arg}`)],91 ];92 }93 104-test.each(getMultipleArgCases('<first>', '[second]'))(105- 'when add two arguments using %s then two arguments',106- (methodName, cmd) => {107- expect(cmd.registeredArguments[0].name()).toEqual('first');108- expect(cmd.registeredArguments[1].name()).toEqual('second');109- },110-);94+describe('when add two arguments then two arguments', () => {95+ getMultipleArgCases('<first>', '[second]').forEach(([methodName, cmd]) => {96+ test(`using ${methodName}`, () => {97+ assert.equal(cmd.registeredArguments[0].name(), 'first');98+ assert.equal(cmd.registeredArguments[1].name(), 'second');99+ });100+ });101+});102 103 function getMultipleArgCases(arg1, arg2) {104 return [105 ['.arguments', new commander.Command().arguments(`${arg1} ${arg2}`)],15 unmodified lines121 cmd.arguments('<arg3> <arg4>');122 cmd.argument('<arg5>');123 cmd.addArgument(new commander.Argument('arg6'));124 const argNames = cmd.registeredArguments.map((arg) => arg.name());134- expect(argNames).toEqual(['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6']);125+ assert.deepEqual(argNames, ['arg1', 'arg2', 'arg3', 'arg4', 'arg5', 'arg6']);126 });modified:tests/command.asterisk.test.js+48 added-56 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // .command('*') is the old main/default command handler. It adds a listener7 // for 'command:*'. It has been somewhat replaced by the program action handler,8 // so most uses are probably old code. Current plan is keep the code backwards compatible4 unmodified lines13 //14 // Historical: the event 'command:*' used to also be shared by the action handler on the program.15 16 describe(".command('*')", () => {14- test('when no arguments then asterisk action not called', () => {15- const writeMock = jest16- .spyOn(process.stderr, 'write')17- .mockImplementation(() => {});18- const mockAction = jest.fn();19- const program = new commander.Command();20- program21- .exitOverride() // to catch help22- .command('*')23- .action(mockAction);17+ test('when no arguments then asterisk action not called', (t) => {18+ const mockAction = t.mock.fn();19+ const program = createTestCommand();20+ program.command('*').action(mockAction);21 try {22 program.parse(['node', 'test']);23 } catch (err) {24 /* empty */25 }29- expect(mockAction).not.toHaveBeenCalled();30- writeMock.mockRestore();26+ assert.equal(mockAction.mock.callCount(), 0);27 });28 33- test('when unrecognised argument then asterisk action called', () => {34- const mockAction = jest.fn();29+ test('when unrecognised argument then asterisk action called', (t) => {30+ const mockAction = t.mock.fn();31 const program = new commander.Command();32 program.command('*').argument('[args...]').action(mockAction);33 program.parse(['node', 'test', 'unrecognised-command']);38- expect(mockAction).toHaveBeenCalled();34+ assert.equal(mockAction.mock.callCount(), 1);35 });36 41- test('when recognised command then asterisk action not called', () => {42- const mockAction = jest.fn();37+ test('when recognised command then asterisk action not called', (t) => {38+ const mockAction = t.mock.fn();39 const program = new commander.Command();40 program.command('install').action(() => {});41 program.command('*').action(mockAction);42 program.parse(['node', 'test', 'install']);47- expect(mockAction).not.toHaveBeenCalled();43+ assert.equal(mockAction.mock.callCount(), 0);44 });45 50- test('when unrecognised command/argument then asterisk action called', () => {51- const mockAction = jest.fn();46+ test('when unrecognised command/argument then asterisk action called', (t) => {47+ const mockAction = t.mock.fn();48 const program = new commander.Command();49 program.command('install');50 program.command('*').argument('[args...]').action(mockAction);51 program.parse(['node', 'test', 'unrecognised-command']);56- expect(mockAction).toHaveBeenCalled();52+ assert.equal(mockAction.mock.callCount(), 1);53 });54 59- test('when unrecognised argument and known option then asterisk action called', () => {55+ test('when unrecognised argument and known option then asterisk action called', (t) => {56 // This tests for a regression between v4 and v5. Known default option should not be rejected by program.61- const mockAction = jest.fn();57+ const mockAction = t.mock.fn();58 const program = new commander.Command();59 program.command('install');60 const star = program61 .command('*')62 .argument('[args...]')63 .option('-d, --debug')64 .action(mockAction);65 program.parse(['node', 'test', 'unrecognised-command', '--debug']);70- expect(mockAction).toHaveBeenCalled();71- expect(star.opts().debug).toEqual(true);66+ assert.equal(mockAction.mock.callCount(), 1);67+ assert.equal(star.opts().debug, true);68 });69 74- test('when non-command argument and unknown option then error for unknown option', () => {70+ test('when non-command argument and unknown option then error for unknown option', (t) => {71 // This is a change in behaviour from v2 which did not error, but is consistent with modern better detection of invalid options76- const mockAction = jest.fn();77- const program = new commander.Command();78- program79- .exitOverride()80- .configureOutput({81- writeErr: () => {},82- })83- .command('install');72+ const mockAction = t.mock.fn();73+ const program = createTestCommand();74+ program.command('install');75 program.command('*').argument('[args...]').action(mockAction);85- let caughtErr;86- try {87- program.parse(['node', 'test', 'some-argument', '--unknown']);88- } catch (err) {89- caughtErr = err;90- }91- expect(caughtErr.code).toEqual('commander.unknownOption');76+ assert.throws(77+ () => {78+ program.parse(['node', 'test', 'some-argument', '--unknown']);79+ },80+ {81+ code: 'commander.unknownOption',82+ },83+ );84 });85 });86 87 // Test .on explicitly rather than assuming covered by .command88 describe(".on('command:*')", () => {97- test('when no arguments then listener not called', () => {98- const mockAction = jest.fn();89+ test('when no arguments then listener not called', (t) => {90+ const mockAction = t.mock.fn();91 const program = new commander.Command();92 program.on('command:*', mockAction);93 program.parse(['node', 'test']);102- expect(mockAction).not.toHaveBeenCalled();94+ assert.equal(mockAction.mock.callCount(), 0);95 });96 105- test('when unrecognised argument then listener called', () => {106- const mockAction = jest.fn();97+ test('when unrecognised argument then listener called', (t) => {98+ const mockAction = t.mock.fn();99 const program = new commander.Command();100 program.on('command:*', mockAction);101 program.parse(['node', 'test', 'unrecognised-command']);110- expect(mockAction).toHaveBeenCalled();102+ assert.equal(mockAction.mock.callCount(), 1);103 });104 113- test('when recognised command then listener not called', () => {114- const mockAction = jest.fn();105+ test('when recognised command then listener not called', (t) => {106+ const mockAction = t.mock.fn();107 const program = new commander.Command();108 program.command('install').action(() => {});109 program.on('command:*', mockAction);110 program.parse(['node', 'test', 'install']);119- expect(mockAction).not.toHaveBeenCalled();111+ assert.equal(mockAction.mock.callCount(), 0);112 });113 122- test('when unrecognised command/argument then listener called', () => {123- const mockAction = jest.fn();114+ test('when unrecognised command/argument then listener called', (t) => {115+ const mockAction = t.mock.fn();116 const program = new commander.Command();117 program.command('install');118 program.on('command:*', mockAction);119 program.parse(['node', 'test', 'unrecognised-command']);128- expect(mockAction).toHaveBeenCalled();120+ assert.equal(mockAction.mock.callCount(), 1);121 });122 131- test('when unrecognised command/argument and unknown option then listener called', () => {123+ test('when unrecognised command/argument and unknown option then listener called', (t) => {124 // Give listener a chance to make a suggestion for misspelled command. The option125 // could only be unknown because the command is not correct.126 // Regression identified in https://github.com/tj/commander.js/issues/1460#issuecomment-772313494135- const mockAction = jest.fn();127+ const mockAction = t.mock.fn();128 const program = new commander.Command();129 program.command('install');130 program.on('command:*', mockAction);131 program.parse(['node', 'test', 'intsall', '--unknown']);140- expect(mockAction).toHaveBeenCalled();132+ assert.equal(mockAction.mock.callCount(), 1);133 });134 });modified:tests/command.chain.test.js+49 added-47 removed
1 const { Command, Option, Argument } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Testing the functions which should chain.6 // parse and parseAsync are tested in command.parse.test.js7 8 describe('Command methods that should return this for chaining', () => {9 test('when call .command() with description for stand-alone executable then returns this', () => {10 const program = new Command();11 const result = program.command('foo', 'foo description');10- expect(result).toBe(program);12+ assert.equal(result, program);13 });14 15 test('when call .addCommand() then returns this', () => {16 const program = new Command();17 const result = program.addCommand(new Command('name'));16- expect(result).toBe(program);18+ assert.equal(result, program);19 });20 21 test('when call .argument() then returns this', () => {22 const program = new Command();23 const result = program.argument('<file>');22- expect(result).toBe(program);24+ assert.equal(result, program);25 });26 27 test('when call .addArgument() then returns this', () => {28 const program = new Command();29 const result = program.addArgument(new Argument('<file>'));28- expect(result).toBe(program);30+ assert.equal(result, program);31 });32 33 test('when set .arguments() then returns this', () => {34 const program = new Command();35 const result = program.arguments('<file>');34- expect(result).toBe(program);36+ assert.equal(result, program);37 });38 39 test('when call .addHelpCommand(cmd) then returns this', () => {40 const program = new Command();41 const result = program.addHelpCommand(new Command('assist'));40- expect(result).toBe(program);42+ assert.equal(result, program);43 });44 45 test('when call deprecated .addHelpCommand() then returns this', () => {46 const program = new Command();47 const result = program.addHelpCommand();46- expect(result).toBe(program);48+ assert.equal(result, program);49 });50 51 test('when call deprecated .addHelpCommand(boolean) then returns this', () => {52 const program = new Command();53 const result1 = program.addHelpCommand(true);52- expect(result1).toBe(program);54+ assert.equal(result1, program);55 const result2 = program.addHelpCommand(false);54- expect(result2).toBe(program);56+ assert.equal(result2, program);57 });58 59 test('when call deprecated .addHelpCommand(string[, string]) then returns this', () => {60 const program = new Command();61 const result1 = program.addHelpCommand('assist');60- expect(result1).toBe(program);62+ assert.equal(result1, program);63 const result2 = program.addHelpCommand('assist', 'assist description');62- expect(result2).toBe(program);64+ assert.equal(result2, program);65 });66 67 test('when call .helpCommand(name) then returns this', () => {68 const program = new Command();69 const result = program.helpCommand();68- expect(result).toBe(program);70+ assert.equal(result, program);71 });72 73 test('when call .helpCommand(name, description) then returns this', () => {74 const program = new Command();75 const result1 = program.helpCommand('assist', 'assist description');74- expect(result1).toBe(program);76+ assert.equal(result1, program);77 });78 79 test('when call .helpCommand(boolean) then returns this', () => {80 const program = new Command();81 const result1 = program.helpCommand(true);80- expect(result1).toBe(program);82+ assert.equal(result1, program);83 const result2 = program.helpCommand(false);82- expect(result2).toBe(program);84+ assert.equal(result2, program);85 });86 87 test('when call .exitOverride() then returns this', () => {88 const program = new Command();89 const result = program.exitOverride(() => {});88- expect(result).toBe(program);90+ assert.equal(result, program);91 });92 93 test('when call .action() then returns this', () => {94 const program = new Command();95 const result = program.action(() => {});94- expect(result).toBe(program);96+ assert.equal(result, program);97 });98 99 test('when call .addOption() then returns this', () => {100 const program = new Command();101 const result = program.addOption(new Option('-e'));100- expect(result).toBe(program);102+ assert.equal(result, program);103 });104 105 test('when call .option() then returns this', () => {106 const program = new Command();107 const result = program.option('-e');106- expect(result).toBe(program);108+ assert.equal(result, program);109 });110 111 test('when call .requiredOption() then returns this', () => {112 const program = new Command();113 const result = program.requiredOption('-r');112- expect(result).toBe(program);114+ assert.equal(result, program);115 });116 117 test('when call .combineFlagAndOptionalValue() then returns this', () => {118 const program = new Command();119 const result = program.combineFlagAndOptionalValue();118- expect(result).toBe(program);120+ assert.equal(result, program);121 });122 123 test('when call .allowUnknownOption() then returns this', () => {124 const program = new Command();125 const result = program.allowUnknownOption();124- expect(result).toBe(program);126+ assert.equal(result, program);127 });128 129 test('when call .allowExcessArguments() then returns this', () => {130 const program = new Command();131 const result = program.allowExcessArguments();130- expect(result).toBe(program);132+ assert.equal(result, program);133 });134 135 test('when call .storeOptionsAsProperties() then returns this', () => {136 const program = new Command();137 const result = program.storeOptionsAsProperties();136- expect(result).toBe(program);138+ assert.equal(result, program);139 });140 141 test('when call .version() then returns this', () => {142 const program = new Command();143 const result = program.version('1.2.3');142- expect(result).toBe(program);144+ assert.equal(result, program);145 });146 147 test('when set .description() then returns this', () => {148 const program = new Command();149 const result = program.description('description');148- expect(result).toBe(program);150+ assert.equal(result, program);151 });152 153 test('when set .alias() then returns this', () => {154 const program = new Command();155 const result = program.alias('alias');154- expect(result).toBe(program);156+ assert.equal(result, program);157 });158 159 test('when set .aliases() then returns this', () => {160 const program = new Command();161 const result = program.aliases(['foo', 'bar']);160- expect(result).toBe(program);162+ assert.equal(result, program);163 });164 165 test('when set .usage() then returns this', () => {166 const program = new Command();167 const result = program.usage('[options]');166- expect(result).toBe(program);168+ assert.equal(result, program);169 });170 171 test('when set .name() then returns this', () => {172 const program = new Command();173 const result = program.name('easy');172- expect(result).toBe(program);174+ assert.equal(result, program);175 });176 177 test('when call .helpOption(flags) then returns this', () => {178 const program = new Command();179 const flags = '-h, --help';180 const result = program.helpOption(flags);179- expect(result).toBe(program);181+ assert.equal(result, program);182 });183 184 test('when call .addHelpOption() then returns this', () => {185 const program = new Command();186 const result = program.addHelpOption(new Option('-h, --help'));185- expect(result).toBe(program);187+ assert.equal(result, program);188 });189 190 test('when call .addHelpText() then returns this', () => {191 const program = new Command();192 const result = program.addHelpText('before', 'example');191- expect(result).toBe(program);193+ assert.equal(result, program);194 });195 196 test('when call .configureHelp() then returns this', () => {197 const program = new Command();198 const result = program.configureHelp({});197- expect(result).toBe(program);199+ assert.equal(result, program);200 });201 202 test('when call .configureOutput() then returns this', () => {203 const program = new Command();204 const result = program.configureOutput({});203- expect(result).toBe(program);205+ assert.equal(result, program);206 });207 208 test('when call .passThroughOptions() then returns this', () => {209 const program = new Command();210 const result = program.passThroughOptions();209- expect(result).toBe(program);211+ assert.equal(result, program);212 });213 214 test('when call .enablePositionalOptions() then returns this', () => {215 const program = new Command();216 const result = program.enablePositionalOptions();215- expect(result).toBe(program);217+ assert.equal(result, program);218 });219 220 test('when call .hook() then returns this', () => {221 const program = new Command();222 const result = program.hook('preAction', () => {});221- expect(result).toBe(program);223+ assert.equal(result, program);224 });225 226 test('when call .setOptionValue() then returns this', () => {227 const program = new Command();228 const result = program.setOptionValue('foo', 'bar');227- expect(result).toBe(program);229+ assert.equal(result, program);230 });231 232 test('when call .setOptionValueWithSource() then returns this', () => {233 const program = new Command();234 const result = program.setOptionValueWithSource('foo', 'bar', 'cli');233- expect(result).toBe(program);235+ assert.equal(result, program);236 });237 238 test('when call .showHelpAfterError() then returns this', () => {239 const program = new Command();240 const result = program.showHelpAfterError();239- expect(result).toBe(program);241+ assert.equal(result, program);242 });243 244 test('when call .showSuggestionAfterError() then returns this', () => {245 const program = new Command();246 const result = program.showSuggestionAfterError();245- expect(result).toBe(program);247+ assert.equal(result, program);248 });249 250 test('when call .copyInheritedSettings() then returns this', () => {251 const program = new Command();252 const cmd = new Command();253 const result = cmd.copyInheritedSettings(program);252- expect(result).toBe(cmd);254+ assert.equal(result, cmd);255 });256 257 test('when set .nameFromFilename() then returns this', () => {258 const program = new Command();259 const result = program.nameFromFilename('name');258- expect(result).toBe(program);260+ assert.equal(result, program);261 });262 263 test('when set .helpGroup(heading) then returns this', () => {264 const program = new Command();265 const result = program.helpGroup('Commands:');264- expect(result).toBe(program);266+ assert.equal(result, program);267 });268 269 test('when set .commandsGroup(heading) then returns this', () => {270 const program = new Command();271 const result = program.commandsGroup('Commands:');270- expect(result).toBe(program);272+ assert.equal(result, program);273 });274 275 test('when set .optionsGroup(heading) then returns this', () => {276 const program = new Command();277 const result = program.optionsGroup('Options:');276- expect(result).toBe(program);278+ assert.equal(result, program);279 });280 });modified:tests/command.commandHelp.test.js+4 added-2 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // This is a ported legacy test.6 7 test('when program has command then appears in help', () => {8 const program = new commander.Command();9 program.command('bare');10 const commandHelp = program.helpInformation();9- expect(commandHelp).toMatch(/Commands:\n +bare\n/);11+ assert.match(commandHelp, /Commands:\n +bare\n/);12 });13 14 test('when program has command with optional arg then appears in help', () => {15 const program = new commander.Command();16 program.command('bare [bare-arg]');17 const commandHelp = program.helpInformation();16- expect(commandHelp).toMatch(/Commands:\n +bare \[bare-arg\]\n/);18+ assert.match(commandHelp, /Commands:\n +bare \[bare-arg\]\n/);19 });modified:tests/command.configureHelp.test.js+6 added-4 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when configure program then affects program helpInformation', () => {6 const program = new commander.Command();7 program.configureHelp({8 formatHelp: () => {9 return 'custom';10 },11 });10- expect(program.helpInformation()).toEqual('custom');12+ assert.equal(program.helpInformation(), 'custom');13 });14 15 test('when configure program then affects subcommand helpInformation', () => {16 const program = new commander.Command();2 unmodified lines19 return 'custom';20 },21 });22 const sub = program.command('sub');21- expect(sub.helpInformation()).toEqual('custom');23+ assert.equal(sub.helpInformation(), 'custom');24 });25 26 test('when configure with unknown property then createHelp has unknown property', () => {27 const program = new commander.Command();28 program.configureHelp({ mySecretValue: 'secret' });27- expect(program.createHelp().mySecretValue).toEqual('secret');29+ assert.equal(program.createHelp().mySecretValue, 'secret');30 });31 32 test('when configure with unknown property then helper passed to formatHelp has unknown property', () => {33 const program = new commander.Command();2 unmodified lines36 formatHelp: (cmd, helper) => {37 return helper.mySecretValue;38 },39 });38- expect(program.helpInformation()).toEqual('secret');40+ assert.equal(program.helpInformation(), 'secret');41 });modified:tests/command.configureOutput.test.js+89 added-111 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 const process = require('node:process');5 4-test('when default writeErr() then error on stderr', () => {5- const writeSpy = jest6- .spyOn(process.stderr, 'write')7- .mockImplementation(() => {});6+test('when default writeErr() then error on stderr', (t) => {7+ const writeSpy = t.mock.method(process.stderr, 'write', () => {});8 const program = new commander.Command();9 program.exitOverride();10 11 try {1 unmodified line13 } catch (err) {14 /* empty */15 }16 17- expect(writeSpy).toHaveBeenCalledTimes(1);18- writeSpy.mockRestore();17+ assert.equal(writeSpy.mock.callCount(), 1);18 });19 21-test('when custom writeErr() then error on custom output', () => {22- const writeSpy = jest23- .spyOn(process.stderr, 'write')24- .mockImplementation(() => {});25- const customWrite = jest.fn();20+test('when custom writeErr() then error on custom output', (t) => {21+ const writeSpy = t.mock.method(process.stderr, 'write', () => {});22+ const customWrite = t.mock.fn();23 const program = new commander.Command();24 program.exitOverride().configureOutput({ writeErr: customWrite });25 26 try {1 unmodified line28 } catch (err) {29 /* empty */30 }31 35- expect(writeSpy).toHaveBeenCalledTimes(0);36- expect(customWrite).toHaveBeenCalledTimes(1);37- writeSpy.mockRestore();32+ assert.equal(writeSpy.mock.callCount(), 0);33+ assert.equal(customWrite.mock.callCount(), 1);34 });35 40-test('when default write() then version on stdout', () => {41- const writeSpy = jest42- .spyOn(process.stdout, 'write')43- .mockImplementation(() => {});36+test('when default write() then version on stdout', (t) => {37+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});38 const program = new commander.Command();39 program.exitOverride().version('1.2.3');40 47- expect(() => {41+ assert.throws(() => {42 program.parse(['--version'], { from: 'user' });49- }).toThrow();43+ });44 51- expect(writeSpy).toHaveBeenCalledTimes(1);52- writeSpy.mockRestore();45+ assert.equal(writeSpy.mock.callCount(), 1);46 });47 55-test('when custom write() then version on custom output', () => {56- const writeSpy = jest57- .spyOn(process.stdout, 'write')58- .mockImplementation(() => {});59- const customWrite = jest.fn();48+test('when custom write() then version on custom output', (t) => {49+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});50+ const customWrite = t.mock.fn();51 const program = new commander.Command();52 program53 .exitOverride()54 .version('1.2.3')55 .configureOutput({ writeOut: customWrite });56 66- expect(() => {57+ assert.throws(() => {58 program.parse(['--version'], { from: 'user' });68- }).toThrow();59+ });60 70- expect(writeSpy).toHaveBeenCalledTimes(0);71- expect(customWrite).toHaveBeenCalledTimes(1);72- writeSpy.mockRestore();61+ assert.equal(writeSpy.mock.callCount(), 0);62+ assert.equal(customWrite.mock.callCount(), 1);63 });64 75-test('when default write() then help on stdout', () => {76- const writeSpy = jest77- .spyOn(process.stdout, 'write')78- .mockImplementation(() => {});65+test('when default write() then help on stdout', (t) => {66+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});67 const program = new commander.Command();68 program.outputHelp();69 82- expect(writeSpy).toHaveBeenCalledTimes(1);83- writeSpy.mockRestore();70+ assert.equal(writeSpy.mock.callCount(), 1);71 });72 86-test('when custom write() then help error on custom output', () => {87- const writeSpy = jest88- .spyOn(process.stdout, 'write')89- .mockImplementation(() => {});90- const customWrite = jest.fn();73+test('when custom write() then help error on custom output', (t) => {74+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});75+ const customWrite = t.mock.fn();76 const program = new commander.Command();77 program.configureOutput({ writeOut: customWrite });78 program.outputHelp();79 95- expect(writeSpy).toHaveBeenCalledTimes(0);96- expect(customWrite).toHaveBeenCalledTimes(1);97- writeSpy.mockRestore();80+ assert.equal(writeSpy.mock.callCount(), 0);81+ assert.equal(customWrite.mock.callCount(), 1);82 });83 100-test('when default writeErr then help error on stderr', () => {101- const writeSpy = jest102- .spyOn(process.stderr, 'write')103- .mockImplementation(() => {});84+test('when default writeErr then help error on stderr', (t) => {85+ const writeSpy = t.mock.method(process.stderr, 'write', () => {});86 const program = new commander.Command();87 program.outputHelp({ error: true });88 107- expect(writeSpy).toHaveBeenCalledTimes(1);108- writeSpy.mockRestore();89+ assert.equal(writeSpy.mock.callCount(), 1);90 });91 111-test('when custom writeErr then help error on custom output', () => {112- const writeSpy = jest113- .spyOn(process.stderr, 'write')114- .mockImplementation(() => {});115- const customWrite = jest.fn();92+test('when custom writeErr then help error on custom output', (t) => {93+ const writeSpy = t.mock.method(process.stderr, 'write', () => {});94+ const customWrite = t.mock.fn();95 const program = new commander.Command();96 program.configureOutput({ writeErr: customWrite });97 program.outputHelp({ error: true });98 120- expect(writeSpy).toHaveBeenCalledTimes(0);121- expect(customWrite).toHaveBeenCalledTimes(1);122- writeSpy.mockRestore();99+ assert.equal(writeSpy.mock.callCount(), 0);100+ assert.equal(customWrite.mock.callCount(), 1);101 });102 103 test('when default getOutHelpWidth then help helpWidth from stdout', () => {104 const expectedColumns = 123;12 unmodified lines117 },118 });119 program.outputHelp();120 143- expect(helpWidth).toBe(expectedColumns);121+ assert.equal(helpWidth, expectedColumns);122 process.stdout.columns = holdColumns;123 process.stdout.isTTY = holdIsTTY;124 });125 13 unmodified lines139 getOutHelpWidth: () => expectedColumns,140 });141 program.outputHelp();142 165- expect(helpWidth).toBe(expectedColumns);143+ assert.equal(helpWidth, expectedColumns);144 });145 146 test('when default getErrHelpWidth then help error helpWidth from stderr', () => {147 const expectedColumns = 123;11 unmodified lines159 },160 });161 program.outputHelp({ error: true });162 185- expect(helpWidth).toBe(expectedColumns);163+ assert.equal(helpWidth, expectedColumns);164 process.stderr.isTTY = holdIsTTY;165 process.stderr.columns = holdColumns;166 });167 13 unmodified lines181 getErrHelpWidth: () => expectedColumns,182 });183 program.outputHelp({ error: true });184 207- expect(helpWidth).toBe(expectedColumns);185+ assert.equal(helpWidth, expectedColumns);186 });187 188 test('when custom getOutHelpWidth and configureHelp:helpWidth then help helpWidth from configureHelp', () => {189 const expectedColumns = 123;12 unmodified lines202 getOutHelpWidth: () => 999,203 });204 program.outputHelp();205 228- expect(helpWidth).toBe(expectedColumns);206+ assert.equal(helpWidth, expectedColumns);207 });208 209 test('when custom getErrHelpWidth and configureHelp:helpWidth then help error helpWidth from configureHelp', () => {210 const expectedColumns = 123;12 unmodified lines223 getErrHelpWidth: () => 999,224 });225 program.outputHelp({ error: true });226 249- expect(helpWidth).toBe(expectedColumns);227+ assert.equal(helpWidth, expectedColumns);228 });229 230 test('when no custom setup and call formatHelp direct then effective helpWidth is fallback 80', () => {231 // Not an important case, but filling out testing coverage.6 unmodified lines238 const program = new commander.Command()239 .description('description')240 .helpOption(false);241 helper.formatHelp(program, helper);264- expect(wrapWidth).toBe(80);242+ assert.equal(wrapWidth, 80);243 });244 245 test('when no custom setup and call formatItem direct then effective helpWidth is fallback 80', () => {246 // Not an important case, but filling out testing coverage.9 unmodified lines256 const itemIndent = 2;257 const spacerWidth = 2; // between term and description258 const remainingWidth = 80 - termWidth - spacerWidth - itemIndent;259 282- expect(wrapWidth).toBe(remainingWidth);260+ assert.equal(wrapWidth, remainingWidth);261 });262 285-test('when set configureOutput then get configureOutput', () => {263+test('when set configureOutput then get configureOutput', (t) => {264 const outputOptions = {287- writeOut: jest.fn(),288- writeErr: jest.fn(),289- getOutHelpWidth: jest.fn(),290- getErrHelpWidth: jest.fn(),291- getOutHasColors: jest.fn(),292- getErrHasColors: jest.fn(),293- outputError: jest.fn(),294- stripColor: jest.fn(),265+ writeOut: t.mock.fn(),266+ writeErr: t.mock.fn(),267+ getOutHelpWidth: t.mock.fn(),268+ getErrHelpWidth: t.mock.fn(),269+ getOutHasColors: t.mock.fn(),270+ getErrHasColors: t.mock.fn(),271+ outputError: t.mock.fn(),272+ stripColor: t.mock.fn(),273 };274 const program = new commander.Command();275 program.configureOutput(outputOptions);298- expect(program.configureOutput()).toEqual(outputOptions);276+ assert.deepEqual(program.configureOutput(), outputOptions);277 });278 301-test('when custom outputErr and error then outputErr called', () => {302- const outputError = jest.fn();279+test('when custom outputErr and error then outputErr called', (t) => {280+ const outputError = t.mock.fn();281 const program = new commander.Command();282 program.exitOverride().configureOutput({283 outputError,284 });285 308- expect(() => {286+ assert.throws(() => {287 program.parse(['--unknownOption'], { from: 'user' });310- }).toThrow();311- expect(outputError).toHaveBeenCalledWith(288+ });289+ assert.equal(290+ outputError.mock.calls[0].arguments[0],291 "error: unknown option '--unknownOption'\n",292+ );293+ assert.equal(294+ outputError.mock.calls[0].arguments[1],295 program._outputConfiguration.writeErr,296 );297 });298 317-test('when custom outputErr and writeErr and error then outputErr passed writeErr', () => {318- const writeErr = () => jest.fn();319- const outputError = jest.fn();299+test('when custom outputErr and writeErr and error then outputErr passed writeErr', (t) => {300+ const writeErr = () => t.mock.fn();301+ const outputError = t.mock.fn();302 const program = new commander.Command();303 program.exitOverride().configureOutput({ writeErr, outputError });304 323- expect(() => {305+ assert.throws(() => {306 program.parse(['--unknownOption'], { from: 'user' });325- }).toThrow();326- expect(outputError).toHaveBeenCalledWith(307+ });308+ assert.equal(309+ outputError.mock.calls[0].arguments[0],310 "error: unknown option '--unknownOption'\n",328- writeErr,311 );312+ assert.equal(outputError.mock.calls[0].arguments[1], writeErr);313 });314 315 test('when configureOutput after copyInheritedSettings then original unchanged', () => {316 const program = new commander.Command();317 program.configureOutput({ getOutHelpWidth: () => 80 });318 const copy = program.createCommand('copy');319 copy.copyInheritedSettings(program);337- expect(copy.configureOutput().getOutHelpWidth()).toBe(80);320+ assert.equal(copy.configureOutput().getOutHelpWidth(), 80);321 copy.configureOutput({ getOutHelpWidth: () => 40 });339- expect(copy.configureOutput().getOutHelpWidth()).toBe(40);340- expect(program.configureOutput().getOutHelpWidth()).toBe(80);322+ assert.equal(copy.configureOutput().getOutHelpWidth(), 40);323+ assert.equal(program.configureOutput().getOutHelpWidth(), 80);324 });325 343-describe.each([['getOutHasColors'], ['getErrHasColors']])(344- '%s',345- (configProperty) => {346- // Tried and failed to mock/modify process.stdout.isTTY to test that part of implementation.347- // Just test overrides work as expected!348-349- const getHasColors = new commander.Command().configureOutput()[350- configProperty351- ];352-353- test.each([354- [true, 'NO_COLOR', false],355- [false, 'FORCE_COLOR', true],356- [false, 'CLICOLOR_FORCE', true],357- ])('when isTTY=%o but %s then returns %o', (isTTY, envvar, result) => {326+describe('environment variable tests', () => {327+ [328+ ['NO_COLOR', false],329+ ['FORCE_COLOR', true],330+ ['CLICOLOR_FORCE', true],331+ ].forEach(([envvar, expected]) => {332+ test(`when ${envvar} then getFooHasColors returns ${expected}`, () => {333+ // Would like to vary process.istty too, but too hard, so tests here provide only partial cover.334 const holdEnv = process.env[envvar];335 process.env[envvar] = '1';360- expect(getHasColors()).toBe(result);336+ const config = new commander.Command().configureOutput();337+ assert.equal(config.getOutHasColors(), expected);338+ assert.equal(config.getErrHasColors(), expected);339 if (holdEnv === undefined) delete process.env[envvar];340 else process.env[envvar] = holdEnv;341 });364- },365-);342+ });343+});modified:tests/command.copySettings.test.js+26 added-23 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Tests some private properties as simpler than pure tests of observable behaviours.6 // Testing before and after values in some cases, to ensure value actually changes (when copied).7 6-test('when add subcommand with .command() then calls copyInheritedSettings from parent', () => {8+test('when add subcommand with .command() then calls copyInheritedSettings from parent', (t) => {9 const program = new commander.Command();10 11 // This is a bit intrusive, but check expectation that copyInheritedSettings is called internally.10- const copySettingMock = jest.fn();12+ const copySettingMock = t.mock.fn();13 program.createCommand = (name) => {14 const cmd = new commander.Command(name);15 cmd.copyInheritedSettings = copySettingMock;16 return cmd;17 };18 program.command('sub');19 18- expect(copySettingMock).toHaveBeenCalledWith(program);20+ const callArgs = copySettingMock.mock.calls[0].arguments;21+ assert.equal(callArgs[0], program);22 });23 24 describe('copyInheritedSettings property tests', () => {25 test('when copyInheritedSettings then copies outputConfiguration(config)', () => {1 unmodified line27 const cmd = new commander.Command();28 29 source.configureOutput({ foo: 'bar' });30 cmd.copyInheritedSettings(source);28- expect(cmd.configureOutput().foo).toEqual('bar');31+ assert.equal(cmd.configureOutput().foo, 'bar');32 });33 34 test('when copyInheritedSettings then copies helpOption(false)', () => {35 const source = new commander.Command();36 const cmd = new commander.Command();37 38 source.helpOption(false);39 cmd.copyInheritedSettings(source);37- expect(cmd._getHelpOption()).toBe(null);40+ assert.equal(cmd._getHelpOption(), null);41 });42 43 test('when copyInheritedSettings then copies helpOption(flags, description)', () => {44 const source = new commander.Command();45 const cmd = new commander.Command();46 47 source.helpOption('-Z, --zz', 'ddd');48 cmd.copyInheritedSettings(source);46- expect(cmd._getHelpOption()).toBe(source._getHelpOption());49+ assert.equal(cmd._getHelpOption(), source._getHelpOption());50 // const helpOption = cmd._getHelpOption();51 // expect(helpOption.flags).toBe('-Z, --zz');52 // expect(helpOption.description).toBe('ddd');53 // expect(helpOption.short).toBe('-Z');7 unmodified lines61 source.helpCommand('HELP [cmd]', 'ddd');62 cmd.copyInheritedSettings(source);63 cmd.helpCommand(true); // force enable64 const helpCommand = cmd._getHelpCommand();62- expect(helpCommand).toBeTruthy();63- expect(helpCommand.name()).toBe('HELP');64- expect(helpCommand.description()).toBe('ddd');65+ assert.ok(helpCommand);66+ assert.equal(helpCommand.name(), 'HELP');67+ assert.equal(helpCommand.description(), 'ddd');68 });69 70 test('when copyInheritedSettings then does not copy help enable override', () => {71 const source = new commander.Command();2 unmodified lines74 // Existing behaviour, force enable/disable does not inherit,75 // largely so (probably redundant) program.helpCommand(true) does not inherit to leaf subcommands.76 source.helpCommand(true);77 cmd.copyInheritedSettings(source);75- expect(cmd._addHelpOption).toBeUndefined();78+ assert.equal(cmd._addHelpOption, undefined);79 });80 81 test('when copyInheritedSettings then copies configureHelp(config)', () => {82 const source = new commander.Command();1 unmodified line84 85 const configuration = { foo: 'bar', helpWidth: 123, sortSubcommands: true };86 source.configureHelp(configuration);87 cmd.copyInheritedSettings(source);85- expect(cmd.configureHelp()).toEqual(configuration);88+ assert.deepEqual(cmd.configureHelp(), configuration);89 });90 91 test('when copyInheritedSettings then copies exitOverride()', () => {92 const source = new commander.Command();93 const cmd = new commander.Command();94 92- expect(cmd._exitCallback).toBeFalsy();95+ assert.ok(!cmd._exitCallback);96 source.exitOverride();97 cmd.copyInheritedSettings(source);95- expect(cmd._exitCallback).toBeTruthy(); // actually a function98+ assert.ok(cmd._exitCallback); // actually a function99 });100 101 test('when copyInheritedSettings then copies storeOptionsAsProperties()', () => {102 const source = new commander.Command();103 const cmd = new commander.Command();104 102- expect(cmd._storeOptionsAsProperties).toBeFalsy();105+ assert.ok(!cmd._storeOptionsAsProperties);106 source.storeOptionsAsProperties();107 cmd.copyInheritedSettings(source);105- expect(cmd._storeOptionsAsProperties).toBeTruthy();108+ assert.ok(cmd._storeOptionsAsProperties);109 });110 111 test('when copyInheritedSettings then copies combineFlagAndOptionalValue()', () => {112 const source = new commander.Command();113 const cmd = new commander.Command();114 112- expect(cmd._combineFlagAndOptionalValue).toBeTruthy();115+ assert.ok(cmd._combineFlagAndOptionalValue);116 source.combineFlagAndOptionalValue(false);117 cmd.copyInheritedSettings(source);115- expect(cmd._combineFlagAndOptionalValue).toBeFalsy();118+ assert.ok(!cmd._combineFlagAndOptionalValue);119 });120 121 test('when copyInheritedSettings then copies allowExcessArguments()', () => {122 const source = new commander.Command();123 const cmd = new commander.Command();124 122- expect(cmd._allowExcessArguments).toBeFalsy();125+ assert.ok(!cmd._allowExcessArguments);126 source.allowExcessArguments();127 cmd.copyInheritedSettings(source);125- expect(cmd._allowExcessArguments).toBeTruthy();128+ assert.ok(cmd._allowExcessArguments);129 });130 131 test('when copyInheritedSettings then copies enablePositionalOptions()', () => {132 const source = new commander.Command();133 const cmd = new commander.Command();134 132- expect(cmd._enablePositionalOptions).toBeFalsy();135+ assert.ok(!cmd._enablePositionalOptions);136 source.enablePositionalOptions();137 cmd.copyInheritedSettings(source);135- expect(cmd._enablePositionalOptions).toBeTruthy();138+ assert.ok(cmd._enablePositionalOptions);139 });140 141 test('when copyInheritedSettings then copies showHelpAfterError()', () => {142 const source = new commander.Command();143 const cmd = new commander.Command();144 142- expect(cmd._showHelpAfterError).toBeFalsy();145+ assert.ok(!cmd._showHelpAfterError);146 source.showHelpAfterError();147 cmd.copyInheritedSettings(source);145- expect(cmd._showHelpAfterError).toBeTruthy();148+ assert.ok(cmd._showHelpAfterError);149 });150 });modified:tests/command.createArgument.test.js+8 added-6 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 class MyArgument extends commander.Argument {6 constructor(name, description) {7 super(name, description);14 unmodified lines22 23 test('when override createArgument then used for argument()', () => {24 const program = new MyCommand();25 program.argument('<file>');24- expect(program.registeredArguments.length).toEqual(1);25- expect(program.registeredArguments[0].myProperty).toEqual('MyArgument');26+ assert.equal(program.registeredArguments.length, 1);27+ assert.equal(program.registeredArguments[0].myProperty, 'MyArgument');28 });29 30 test('when override createArgument then used for arguments()', () => {31 const program = new MyCommand();32 program.arguments('<file>');31- expect(program.registeredArguments.length).toEqual(1);32- expect(program.registeredArguments[0].myProperty).toEqual('MyArgument');33+ assert.equal(program.registeredArguments.length, 1);34+ assert.equal(program.registeredArguments[0].myProperty, 'MyArgument');35 });36 37 test('when override createArgument and createCommand then used for argument of command()', () => {38 const program = new MyCommand();39 const sub = program.command('sub <file>');38- expect(sub.registeredArguments.length).toEqual(1);39- expect(sub.registeredArguments[0].myProperty).toEqual('MyArgument');40+ assert.equal(sub.registeredArguments.length, 1);41+ assert.equal(sub.registeredArguments[0].myProperty, 'MyArgument');42 });modified:tests/command.createHelp.test.js+3 added-1 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when override createCommand then affects help', () => {6 class MyHelp extends commander.Help {7 formatHelp(cmd, helper) {7 unmodified lines15 }16 }17 18 const program = new MyCommand();17- expect(program.helpInformation()).toEqual('custom');19+ assert.equal(program.helpInformation(), 'custom');20 });modified:tests/command.createOption.test.js+10 added-8 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 class MyOption extends commander.Option {6 constructor(flags, description) {7 super(flags, description);9 unmodified lines17 18 test('when override createOption then used for option()', () => {19 const program = new MyCommand();20 program.option('-a, --alpha');19- expect(program.options.length).toEqual(1);20- expect(program.options[0].myProperty).toEqual('MyOption');21+ assert.equal(program.options.length, 1);22+ assert.equal(program.options[0].myProperty, 'MyOption');23 });24 25 test('when override createOption then used for requiredOption()', () => {26 const program = new MyCommand();27 program.requiredOption('-a, --alpha');26- expect(program.options.length).toEqual(1);27- expect(program.options[0].myProperty).toEqual('MyOption');28+ assert.equal(program.options.length, 1);29+ assert.equal(program.options[0].myProperty, 'MyOption');30 });31 32 test('when override createOption then used for version()', () => {33 const program = new MyCommand();34 program.version('1.2.3');33- expect(program.options.length).toEqual(1);34- expect(program.options[0].myProperty).toEqual('MyOption');35+ assert.equal(program.options.length, 1);36+ assert.equal(program.options[0].myProperty, 'MyOption');37 });38 39 test('when override createOption then used for help option in visibleOptions', () => {40 const program = new MyCommand();41 const visibleOptions = program.createHelp().visibleOptions(program);40- expect(visibleOptions.length).toEqual(1);41- expect(visibleOptions[0].myProperty).toEqual('MyOption');42+ assert.equal(visibleOptions.length, 1);43+ assert.equal(visibleOptions[0].myProperty, 'MyOption');44 });modified:tests/command.default.test.js+27 added-25 removed
1 const childProcess = require('child_process');2 const commander = require('../');3 const path = require('path');4 const util = require('util');5+const { test, describe } = require('node:test');6+const assert = require('node:assert/strict');7 8 const execFileAsync = util.promisify(childProcess.execFile);9 10 describe('default executable command', () => {1 unmodified line12 const pm = path.join(__dirname, './fixtures/pm');13 14 test('when default subcommand and no command then call default', async () => {15 const { stdout } = await execFileAsync('node', [pm]);14- expect(stdout).toBe('default\n');16+ assert.equal(stdout, 'default\n');17 });18 19 test('when default subcommand and unrecognised argument then call default with argument', async () => {20 const { stdout } = await execFileAsync('node', [pm, 'an-argument']);19- expect(stdout).toBe("default\n[ 'an-argument' ]\n");21+ assert.equal(stdout, "default\n[ 'an-argument' ]\n");22 });23 24 test('when default subcommand and unrecognised option then call default with option', async () => {25 const { stdout } = await execFileAsync('node', [pm, '--an-option']);24- expect(stdout).toBe("default\n[ '--an-option' ]\n");26+ assert.equal(stdout, "default\n[ '--an-option' ]\n");27 });28 });29 30 describe('default action command', () => {29- function makeProgram() {31+ function makeProgram(t) {32 const program = new commander.Command();31- const actionMock = jest.fn();33+ const actionMock = t.mock.fn();34 program.command('other');35 program36 .command('default', { isDefault: true })37 .allowUnknownOption()1 unmodified line39 .action(actionMock);40 return { program, actionMock };41 }42 41- test('when default subcommand and no command then call default', () => {42- const { program, actionMock } = makeProgram();43+ test('when default subcommand and no command then call default', (t) => {44+ const { program, actionMock } = makeProgram(t);45 program.parse('node test.js'.split(' '));44- expect(actionMock).toHaveBeenCalled();46+ assert.equal(actionMock.mock.callCount(), 1);47 });48 47- test('when default subcommand and unrecognised argument then call default', () => {48- const { program, actionMock } = makeProgram();49+ test('when default subcommand and unrecognised argument then call default', (t) => {50+ const { program, actionMock } = makeProgram(t);51 program.parse('node test.js an-argument'.split(' '));50- expect(actionMock).toHaveBeenCalled();52+ assert.equal(actionMock.mock.callCount(), 1);53 });54 53- test('when default subcommand and unrecognised option then call default', () => {54- const { program, actionMock } = makeProgram();55+ test('when default subcommand and unrecognised option then call default', (t) => {56+ const { program, actionMock } = makeProgram(t);57 program.parse('node test.js --an-option'.split(' '));56- expect(actionMock).toHaveBeenCalled();58+ assert.equal(actionMock.mock.callCount(), 1);59 });60 });61 62 describe('default added command', () => {61- function makeProgram() {62- const actionMock = jest.fn();63+ function makeProgram(t) {64+ const actionMock = t.mock.fn();65 const defaultCmd = new commander.Command('default')66 .allowUnknownOption()67 .allowExcessArguments()68 .action(actionMock);3 unmodified lines72 program.addCommand(defaultCmd, { isDefault: true });73 return { program, actionMock };74 }75 74- test('when default subcommand and no command then call default', () => {75- const { program, actionMock } = makeProgram();76+ test('when default subcommand and no command then call default', (t) => {77+ const { program, actionMock } = makeProgram(t);78 program.parse('node test.js'.split(' '));77- expect(actionMock).toHaveBeenCalled();79+ assert.equal(actionMock.mock.callCount(), 1);80 });81 80- test('when default subcommand and unrecognised argument then call default', () => {81- const { program, actionMock } = makeProgram();82+ test('when default subcommand and unrecognised argument then call default', (t) => {83+ const { program, actionMock } = makeProgram(t);84 program.parse('node test.js an-argument'.split(' '));83- expect(actionMock).toHaveBeenCalled();85+ assert.equal(actionMock.mock.callCount(), 1);86 });87 86- test('when default subcommand and unrecognised option then call default', () => {87- const { program, actionMock } = makeProgram();88+ test('when default subcommand and unrecognised option then call default', (t) => {89+ const { program, actionMock } = makeProgram(t);90 program.parse('node test.js --an-option'.split(' '));89- expect(actionMock).toHaveBeenCalled();91+ assert.equal(actionMock.mock.callCount(), 1);92 });93 });modified:tests/command.description.test.js+3 added-1 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when set description then get description', () => {6 const program = new commander.Command();7 const description = 'abcdef';8 program.description(description);7- expect(program.description()).toMatch(description);9+ assert.equal(program.description(), description);10 });modified:tests/command.error.test.js+25 added-30 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 3-test('when error called with message then message displayed on stderr', () => {4- const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});5- const stderrSpy = jest6- .spyOn(process.stderr, 'write')7- .mockImplementation(() => {});5+test('when error called with message then message displayed on stderr', (t) => {6+ t.mock.method(process, 'exit', () => {});7+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});8 9 const program = new commander.Command();10 const message = 'Goodbye';11 program.error(message);12 13- expect(stderrSpy).toHaveBeenCalledWith(`${message}\n`);14- stderrSpy.mockRestore();15- exitSpy.mockRestore();13+ const callArgs = stderrSpy.mock.calls[0].arguments;14+ assert.equal(callArgs[0], `${message}\n`);15 });16 18-test('when error called with no exitCode then process.exit(1)', () => {19- const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});17+test('when error called with no exitCode then process.exit(1)', (t) => {18+ const exitSpy = t.mock.method(process, 'exit', () => {});19 20 const program = new commander.Command();21 program.configureOutput({22 writeErr: () => {},23 });24 25 program.error('Goodbye');26 28- expect(exitSpy).toHaveBeenCalledWith(1);29- exitSpy.mockRestore();27+ const callArgs = exitSpy.mock.calls[0].arguments;28+ assert.equal(callArgs[0], 1);29 });30 32-test('when error called with exitCode 2 then process.exit(2)', () => {33- const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});31+test('when error called with exitCode 2 then process.exit(2)', (t) => {32+ const exitSpy = t.mock.method(process, 'exit', () => {});33 34 const program = new commander.Command();35 program.configureOutput({36 writeErr: () => {},37 });38 program.error('Goodbye', { exitCode: 2 });39 41- expect(exitSpy).toHaveBeenCalledWith(2);42- exitSpy.mockRestore();40+ const callArgs = exitSpy.mock.calls[0].arguments;41+ assert.equal(callArgs[0], 2);42 });43 44 test('when error called with code and exitOverride then throws with code', () => {45 const program = new commander.Command();47- let errorThrown;48- program49- .exitOverride((err) => {50- errorThrown = err;51- throw err;52- })53- .configureOutput({54- writeErr: () => {},55- });46+ program.exitOverride().configureOutput({47+ writeErr: () => {},48+ });49 57- const code = 'commander.test';58- expect(() => {59- program.error('Goodbye', { code });60- }).toThrow();61- expect(errorThrown.code).toEqual(code);50+ const code = 'commander.mytest';51+ assert.throws(52+ () => {53+ program.error('Goodbye', { code });54+ },55+ { code },56+ );57 });modified:tests/command.executableSubcommand.inspect.test.js+10 added-8 removed
1 const childProcess = require('child_process');2 const path = require('path');3 const util = require('util');4+const { test } = require('node:test');5+const assert = require('node:assert/strict');6 7 const execFileAsync = util.promisify(childProcess.execFile);8 9 // Test the special handling for --inspect to increment fixed debug port numbers.2 unmodified lines12 const inspectCommand = path.join(__dirname, './fixtures', 'inspect.js');13 14 test('when execArgv empty then spawn execArgs empty', async () => {15 const { stdout } = await execFileAsync('node', [inspectCommand, 'sub']);14- expect(stdout).toBe('[]\n');16+ assert.equal(stdout, '[]\n');17 });18 19 test('when execArgv --harmony then spawn execArgs --harmony', async () => {20 const { stdout } = await execFileAsync('node', [21 '--harmony',22 inspectCommand,23 'sub',24 ]);23- expect(stdout).toBe("[ '--harmony' ]\n");25+ assert.equal(stdout, "[ '--harmony' ]\n");26 });27 28 // --inspect defaults to 127.0.0.1:9229, port should be incremented29 test('when execArgv --inspect then spawn execArgs using port 9230', async () => {1 unmodified line31 '--inspect',32 inspectCommand,33 'sub',34 ]);33- expect(stdout).toBe("[ '--inspect=127.0.0.1:9230' ]\n");35+ assert.equal(stdout, "[ '--inspect=127.0.0.1:9230' ]\n");36 });37 38 // custom port39 test('when execArgv --inspect=9240 then spawn execArgs using port 9241', async () => {1 unmodified line41 '--inspect=9240',42 inspectCommand,43 'sub',44 ]);43- expect(stdout).toBe("[ '--inspect=127.0.0.1:9241' ]\n");45+ assert.equal(stdout, "[ '--inspect=127.0.0.1:9241' ]\n");46 });47 48 // zero is special, random port49 test('when execArgv --inspect=0 then spawn execArgs --inspect=0', async () => {1 unmodified line51 '--inspect=0',52 inspectCommand,53 'sub',54 ]);53- expect(stdout).toBe("[ '--inspect=0' ]\n");55+ assert.equal(stdout, "[ '--inspect=0' ]\n");56 });57 58 // ip address59 test('when execArgv --inspect=127.0.0.1:9250 then spawn execArgs --inspect=127.0.0.1:9251', async () => {1 unmodified line61 '--inspect=127.0.0.1:9250',62 inspectCommand,63 'sub',64 ]);63- expect(stdout).toBe("[ '--inspect=127.0.0.1:9251' ]\n");65+ assert.equal(stdout, "[ '--inspect=127.0.0.1:9251' ]\n");66 });67 68 // localhost69 test('when execArgv --inspect=localhost:9260 then spawn execArgs --inspect=localhost:9261', async () => {1 unmodified line71 '--inspect=localhost:9260',72 inspectCommand,73 'sub',74 ]);73- expect(stdout).toBe("[ '--inspect=localhost:9261' ]\n");75+ assert.equal(stdout, "[ '--inspect=localhost:9261' ]\n");76 });77 78 // --inspect-port, just test most likely format79 test('when execArgv --inspect-port=9270 then spawn execArgs --inspect-port=127.0.0.1:9271', async () => {1 unmodified line81 '--inspect-port=9270',82 inspectCommand,83 'sub',84 ]);83- expect(stdout).toBe("[ '--inspect-port=127.0.0.1:9271' ]\n");85+ assert.equal(stdout, "[ '--inspect-port=127.0.0.1:9271' ]\n");86 });modified:tests/command.executableSubcommand.lookup.test.js+18 added-23 removed
1 const childProcess = require('child_process');2 const path = require('path');3 const util = require('util');4 const execFileAsync = util.promisify(childProcess.execFile);5+const { test } = require('node:test');6+const assert = require('node:assert/strict');7 8 // Calling node explicitly so pm works without file suffix cross-platform.9 // This file does end-to-end tests actually spawning program.10 // See also command.executableSubcommand.search.test.js11 12 // Suppress false positive warnings due to use of testOrSkipOnWindows11-/* eslint-disable jest/no-standalone-expect */13 14 const testOrSkipOnWindows = process.platform === 'win32' ? test.skip : test;15 const pm = path.join(__dirname, './fixtures/pm');16 17 test('when subcommand file missing then error', () => {17- expect.assertions(1);18 return execFileAsync('node', [pm, 'list']).catch((err) => {19 if (process.platform === 'win32') {20 // Get uncaught thrown error on Windows21- // eslint-disable-next-line jest/no-conditional-expect22- expect(err.stderr).toBeDefined();21+ assert.ok(err.stderr !== undefined);22 } else {24- // eslint-disable-next-line jest/no-conditional-expect25- expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);23+ assert.match(err.stderr, /Error: 'pm-list' does not exist/);24 }25 });26 });27 28 test('when alias subcommand file missing then error', () => {31- expect.assertions(1);29 return execFileAsync('node', [pm, 'lst']).catch((err) => {30 if (process.platform === 'win32') {31 // Get uncaught thrown error on Windows35- // eslint-disable-next-line jest/no-conditional-expect36- expect(err.stderr).toBeDefined();32+ assert.ok(err.stderr !== undefined);33 } else {38- // eslint-disable-next-line jest/no-conditional-expect39- expect(err.stderr).toMatch(/Error: 'pm-list' does not exist/);34+ assert.match(err.stderr, /Error: 'pm-list' does not exist/);35 }36 });37 });38 39 test('when subcommand file has no suffix then lookup succeeds', async () => {40 const { stdout } = await execFileAsync('node', [pm, 'install']);46- expect(stdout).toBe('install\n');41+ assert.equal(stdout, 'install\n');42 });43 44 test('when alias subcommand file has no suffix then lookup succeeds', async () => {45 const { stdout } = await execFileAsync('node', [pm, 'i']);51- expect(stdout).toBe('install\n');46+ assert.equal(stdout, 'install\n');47 });48 49 test('when subcommand target executablefile has no suffix then lookup succeeds', async () => {50 const { stdout } = await execFileAsync('node', [pm, 'specifyInstall']);56- expect(stdout).toBe('install\n');51+ assert.equal(stdout, 'install\n');52 });53 54 test('when subcommand file suffix .js then lookup succeeds', async () => {55 const { stdout } = await execFileAsync('node', [pm, 'publish']);61- expect(stdout).toBe('publish\n');56+ assert.equal(stdout, 'publish\n');57 });58 59 test('when alias subcommand file suffix .js then lookup succeeds', async () => {60 const { stdout } = await execFileAsync('node', [pm, 'p']);66- expect(stdout).toBe('publish\n');61+ assert.equal(stdout, 'publish\n');62 });63 64 test('when subcommand target executablefile has suffix .js then lookup succeeds', async () => {65 const { stdout } = await execFileAsync('node', [pm, 'specifyPublish']);71- expect(stdout).toBe('publish\n');66+ assert.equal(stdout, 'publish\n');67 });68 69 testOrSkipOnWindows(70 'when subcommand file is symlink then lookup succeeds',71 async () => {72 const pmlink = path.join(__dirname, 'fixtures', 'pmlink');73 const { stdout } = await execFileAsync('node', [pmlink, 'install']);79- expect(stdout).toBe('install\n');74+ assert.equal(stdout, 'install\n');75 },76 );77 78 testOrSkipOnWindows(79 'when subcommand file is double symlink then lookup succeeds',80 async () => {81 const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm');82 const { stdout } = await execFileAsync('node', [pmlink, 'install']);88- expect(stdout).toBe('install\n');83+ assert.equal(stdout, 'install\n');84 },85 );86 87 test('when subcommand suffix is .ts then lookup succeeds', async () => {1 unmodified line89 // The subcommand is both plain JavaScript code for this test.90 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');91 // childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) {92 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-ts']);98- expect(stdout).toBe('found .ts\n');93+ assert.equal(stdout, 'found .ts\n');94 });95 96 test('when subcommand suffix is .cjs then lookup succeeds', async () => {97 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');98 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-cjs']);104- expect(stdout).toBe('found .cjs\n');99+ assert.equal(stdout, 'found .cjs\n');100 });101 102 test('when subcommand suffix is .mjs then lookup succeeds', async () => {103 const binLinkTs = path.join(__dirname, 'fixtures-extensions', 'pm.js');104 const { stdout } = await execFileAsync('node', [binLinkTs, 'try-mjs']);110- expect(stdout).toBe('found .mjs\n');105+ assert.equal(stdout, 'found .mjs\n');106 });107 108 test('when subsubcommand then lookup sub-sub-command', async () => {109 const { stdout } = await execFileAsync('node', [pm, 'cache', 'clear']);115- expect(stdout).toBe('cache-clear\n');110+ assert.equal(stdout, 'cache-clear\n');111 });modified:tests/command.executableSubcommand.mock.test.js+32 added-36 removed
1 const commander = require('../');2 const childProcess = require('child_process');3 const EventEmitter = require('events');4+const { test } = require('node:test');5+const assert = require('node:assert/strict');6 7 // Using mock to allow try/catch around what is otherwise out-of-stack error handling.8 // Injecting errors, these are not end-to-end tests.9 4 unmodified lines14 return err;15 }16 17 // Suppress false positive warnings due to use of testOrSkipOnWindows16-/* eslint-disable jest/no-standalone-expect */18 19 const testOrSkipOnWindows = process.platform === 'win32' ? test.skip : test;20 21 testOrSkipOnWindows(22 'when subcommand executable missing (ENOENT) then throw custom message',22- () => {23+ (t) => {24 // If the command is not found, we show a custom error with an explanation and offer25 // some advice for possible fixes.26 const mockProcess = new EventEmitter();26- const spawnSpy = jest27- .spyOn(childProcess, 'spawn')28- .mockImplementation(() => {29- return mockProcess;30- });27+ t.mock.method(childProcess, 'spawn', () => {28+ return mockProcess;29+ });30 const program = new commander.Command();31 program.exitOverride();32 program.command('executable', 'executable description');33 program.parse(['executable'], { from: 'user' });35- expect(() => {34+ assert.throws(() => {35 mockProcess.emit('error', makeSystemError('ENOENT'));37- }).toThrow('use the executableFile option to supply a custom name'); // part of custom message38- spawnSpy.mockRestore();36+ }, /use the executableFile option to supply a custom name/); // part of custom message37 },38 );39 40 testOrSkipOnWindows(41 'when subcommand executable not executable (EACCES) then throw custom message',44- () => {42+ (t) => {43 const mockProcess = new EventEmitter();46- const spawnSpy = jest47- .spyOn(childProcess, 'spawn')48- .mockImplementation(() => {49- return mockProcess;50- });44+ t.mock.method(childProcess, 'spawn', () => {45+ return mockProcess;46+ });47 const program = new commander.Command();48 program.exitOverride();49 program.command('executable', 'executable description');50 program.parse(['executable'], { from: 'user' });55- expect(() => {51+ assert.throws(() => {52 mockProcess.emit('error', makeSystemError('EACCES'));57- }).toThrow('not executable'); // part of custom message58- spawnSpy.mockRestore();53+ }, /not executable/); // part of custom message54 },55 );56 62-test('when subcommand executable fails with other error and exitOverride then return in custom wrapper', () => {57+test('when subcommand executable fails with other error and exitOverride then return in custom wrapper', (t) => {58 // The existing behaviour is to just silently fail for unexpected errors, as it is happening59 // asynchronously in spawned process and client can not catch errors.60 const mockProcess = new EventEmitter();66- const spawnSpy = jest.spyOn(childProcess, 'spawn').mockImplementation(() => {61+ t.mock.method(childProcess, 'spawn', () => {62 return mockProcess;63 });64 const program = new commander.Command();65 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn1 unmodified line67 throw err;68 });69 program.command('executable', 'executable description');70 program.parse(['executable'], { from: 'user' });76- let caughtErr;77- try {78- mockProcess.emit('error', makeSystemError('OTHER'));79- } catch (err) {80- caughtErr = err;81- }82- expect(caughtErr.code).toEqual('commander.executeSubCommandAsync');83- expect(caughtErr.nestedError.code).toEqual('OTHER');84- spawnSpy.mockRestore();71+ assert.throws(72+ () => {73+ mockProcess.emit('error', makeSystemError('OTHER'));74+ },75+ (err) => {76+ assert.equal(err.code, 'commander.executeSubCommandAsync');77+ assert.equal(err.nestedError.code, 'OTHER');78+ return true;79+ },80+ );81 });82 87-test('when subcommand executable fails with other error then exit', () => {83+test('when subcommand executable fails with other error then exit', (t) => {84 // The existing behaviour is to just silently fail for unexpected errors, as it is happening85 // asynchronously in spawned process and client can not catch errors.86 const mockProcess = new EventEmitter();91- const spawnSpy = jest.spyOn(childProcess, 'spawn').mockImplementation(() => {87+ t.mock.method(childProcess, 'spawn', () => {88 return mockProcess;89 });94- const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});90+ const exitSpy = t.mock.method(process, 'exit', () => {});91 const program = new commander.Command();92 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn93 program.command('executable', 'executable description');94 program.parse(['executable'], { from: 'user' });95 mockProcess.emit('error', makeSystemError('OTHER'));100- expect(exitSpy).toHaveBeenCalledWith(1);101- exitSpy.mockRestore();102- spawnSpy.mockRestore();96+ assert.equal(exitSpy.mock.callCount(), 1);97+ const callArgs = exitSpy.mock.calls[0].arguments;98+ assert.equal(callArgs[0], 1);99 });modified:tests/command.executableSubcommand.search.test.js+84 added-89 removed
1 const childProcess = require('child_process');2 const fs = require('fs');3 const path = require('path');4 const commander = require('../');5+const { test, describe } = require('node:test');6+const assert = require('node:assert/strict');7 8 // This file does in-process mocking. Bit clumsy but faster and less external clutter than using fixtures.9 // See also command.executableSubcommand.lookup.test.js for tests using fixtures.10 11 const gLocalDirectory = path.resolve(__dirname, 'fixtures'); // Real directory, although not actually searching for files in it.12 11-function extractMockSpawnArgs(mock) {12- expect(mock).toHaveBeenCalled();13- // non-Win, launchWithNode: childProcess.spawn(process.argv[0], args, { stdio: 'inherit' });14- // Win always: childProcess.spawn(process.execPath, args, { stdio: 'inherit' });15- return mock.mock.calls[0][1];13+function extractMockSpawnArgs(spawnSpy) {14+ assert.equal(spawnSpy.mock.callCount() > 0, true);15+ // This is very fragile on implementation details of how subcommand spawned.16+ // non-Win Jest, launchWithNode: childProcess.spawn(process.argv[0], args, { stdio: 'inherit' });17+ // Win Jest always: childProcess.spawn(process.execPath, args, { stdio: 'inherit' });18+ // node:test passes wild number of node args on front!19+20+ const callArgs = spawnSpy.mock.calls[0].arguments;21+ return callArgs[1].slice(-1); // fingers crossed last arg is filename!22 }23 18-function extractMockSpawnCommand(mock) {19- expect(mock).toHaveBeenCalled();24+function extractMockSpawnCommand(spawnSpy) {25+ assert.equal(spawnSpy.mock.callCount() > 0, true);26 // child_process.spawn(command[, args][, options])21- return mock.mock.calls[0][0];27+ const callArgs = spawnSpy.mock.calls[0].arguments;28+ return callArgs[0];29 }30 31 const describeOrSkipOnWindows =32 process.platform === 'win32' ? describe.skip : describe;33 34 describe('search for subcommand', () => {28- let spawnSpy;29- let existsSpy;30-31- beforeAll(() => {32- spawnSpy = jest.spyOn(childProcess, 'spawn').mockImplementation(() => {35+ function makeSpies(t, existsFn) {36+ const spawnSpy = t.mock.method(childProcess, 'spawn', () => {37 return {38 on: () => {},39 killed: true,40 };41 });38- });42+ const existsSpy = t.mock.method(fs, 'existsSync', existsFn);43+ return { spawnSpy, existsSpy };44+ }45 40- beforeEach(() => {41- existsSpy = jest.spyOn(fs, 'existsSync');42- });43-44- afterEach(() => {45- spawnSpy.mockClear();46- existsSpy.mockRestore();47- });48-49- afterAll(() => {50- spawnSpy.mockRestore();51- });52-46 // fs.existsSync gets called on Windows outside the search, so skip the tests (or come up with a different way of checking).47 describe('whether perform search for local files', () => {55- beforeEach(() => {56- existsSpy.mockImplementation(() => false);57- });58-59- test('when no script arg or executableDir then no search for local file', () => {48+ test('when no script arg or executableDir then no search for local file', (t) => {49+ const { existsSpy } = makeSpies(t, () => false);50 const program = new commander.Command();51 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn52 program.name('pm');53 program.command('sub', 'executable description');54 program.parse(['sub'], { from: 'user' });55 66- expect(existsSpy).not.toHaveBeenCalled();56+ assert.equal(existsSpy.mock.callCount(), 0);57 });58 69- test('when script arg then search for local files', () => {59+ test('when script arg then search for local files', (t) => {60+ const { existsSpy } = makeSpies(t, () => false);61 const program = new commander.Command();62 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn63 program.name('pm');64 program.command('sub', 'executable description');65 program.parse(['node', 'script-name', 'sub']);66 76- expect(existsSpy).toHaveBeenCalled();67+ assert.equal(existsSpy.mock.callCount() > 0, true);68 });69 79- test('when executableDir then search for local files)', () => {70+ test('when executableDir then search for local files)', (t) => {71+ const { existsSpy } = makeSpies(t, () => false);72 const program = new commander.Command();73 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn74 program.name('pm');75 program.executableDir(__dirname);76 program.command('sub', 'executable description');77 program.parse(['sub'], { from: 'user' });78 87- expect(existsSpy).toHaveBeenCalled();79+ assert.equal(existsSpy.mock.callCount() > 0, true);80 });81 });82 83 // We always use node on Windows, and don't spawn executable as the command (which may be a feature or a shortcoming!?).84 describeOrSkipOnWindows(85 'subcommand command name with no matching local file (non-Windows)',86 () => {95- beforeEach(() => {96- existsSpy.mockImplementation(() => false);97- });98-99- test('when named pm and no script arg or executableDir then spawn pm-sub as command', () => {87+ test('when named pm and no script arg or executableDir then spawn pm-sub as command', (t) => {88+ const { spawnSpy } = makeSpies(t, () => false);89 const program = new commander.Command();90 program.name('pm');91 program.command('sub', 'executable description');92 program.parse(['sub'], { from: 'user' });93 105- expect(extractMockSpawnCommand(spawnSpy)).toEqual('pm-sub');94+ assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');95 });96 108- test('when named pm and script arg then still spawn pm-sub as command', () => {97+ test('when named pm and script arg then still spawn pm-sub as command', (t) => {98+ const { spawnSpy } = makeSpies(t, () => false);99 const program = new commander.Command();100 program.name('pm');101 program.command('sub', 'executable description');102 program.parse(['node', 'script-name', 'sub']);103 114- expect(extractMockSpawnCommand(spawnSpy)).toEqual('pm-sub');104+ assert.equal(extractMockSpawnCommand(spawnSpy), 'pm-sub');105 });106 117- test('when no name and script arg then spawn script-sub as command', () => {107+ test('when no name and script arg then spawn script-sub as command', (t) => {108+ const { spawnSpy } = makeSpies(t, () => false);109 const program = new commander.Command();110 program.command('sub', 'executable description');111 program.parse(['node', 'script.js', 'sub']);112 122- expect(extractMockSpawnCommand(spawnSpy)).toEqual('script-sub');113+ assert.equal(extractMockSpawnCommand(spawnSpy), 'script-sub');114 });115 125- test('when named pm and script arg and executableFile then spawn executableFile as command', () => {116+ test('when named pm and script arg and executableFile then spawn executableFile as command', (t) => {117+ const { spawnSpy } = makeSpies(t, () => false);118 const program = new commander.Command();119 program.command('sub', 'executable description', {120 executableFile: 'myExecutable',121 });122 program.parse(['node', 'script.js', 'sub']);123 132- expect(extractMockSpawnCommand(spawnSpy)).toEqual('myExecutable');124+ assert.equal(extractMockSpawnCommand(spawnSpy), 'myExecutable');125 });126 },127 );128 129 describe('subcommand command name with matching local file', () => {138- test('when construct with name pm and script arg then spawn local pm-sub.js', () => {130+ test('when construct with name pm and script arg then spawn local pm-sub.js', (t) => {131 const program = new commander.Command('pm');132 program.command('sub', 'executable description');133 134 const localPath = path.resolve(gLocalDirectory, 'pm-sub.js');143- existsSpy.mockImplementation((path) => path === localPath);135+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);136 program.parse([137 'node',138 path.resolve(gLocalDirectory, 'script.js'),139 'sub',140 ]);141 150- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);142+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);143 });144 153- test('when name pm and script arg then spawn local pm-sub.js', () => {145+ test('when name pm and script arg then spawn local pm-sub.js', (t) => {146 const program = new commander.Command();147 program.name('pm');148 program.command('sub', 'executable description');149 150 const localPath = path.resolve(gLocalDirectory, 'pm-sub.js');159- existsSpy.mockImplementation((path) => path === localPath);151+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);152 program.parse([153 'node',154 path.resolve(gLocalDirectory, 'script.js'),155 'sub',156 ]);157 166- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);158+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);159 });160 169- test('when script arg then spawn local script-sub.js', () => {161+ test('when script arg then spawn local script-sub.js', (t) => {162 const program = new commander.Command();163 program.command('sub', 'executable description');164 165 const localPath = path.resolve(gLocalDirectory, 'script-sub.js');174- existsSpy.mockImplementation((path) => path === localPath);166+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);167 program.parse([168 'node',169 path.resolve(gLocalDirectory, 'script.js'),170 'sub',171 ]);172 181- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);173+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);174 });175 184- test('when name pm and script arg and only script-sub.js then fallback to spawn local script-sub.js', () => {176+ test('when name pm and script arg and only script-sub.js then fallback to spawn local script-sub.js', (t) => {177 const program = new commander.Command();178 program.name('pm');179 program.command('sub', 'executable description');180 181 // Fallback for compatibility with Commander <= v8182 const localPath = path.resolve(gLocalDirectory, 'script-sub.js');191- existsSpy.mockImplementation((path) => path === localPath);183+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);184 program.parse([185 'node',186 path.resolve(gLocalDirectory, 'script.js'),187 'sub',188 ]);189 198- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);190+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);191 });192 201- test('when name pm and executableDir then spawn local pm-sub.js', () => {193+ test('when name pm and executableDir then spawn local pm-sub.js', (t) => {194 const program = new commander.Command();195 program.name('pm');196 program.command('sub', 'executable description');197 198 const execDir = path.resolve(gLocalDirectory, 'exec-dir');199 program.executableDir(execDir);200 const localPath = path.resolve(execDir, 'pm-sub.js');209- existsSpy.mockImplementation((path) => path === localPath);201+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);202 program.parse(['sub'], { from: 'user' });203 212- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);204+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);205 });206 215- test('when script arg and relative executableDir then spawn relative script-sub.js', () => {207+ test('when script arg and relative executableDir then spawn relative script-sub.js', (t) => {208 const program = new commander.Command();209 program.command('sub', 'executable description');210 211 const execDir = 'exec-dir';212 program.executableDir(execDir);213 const localPath = path.resolve(gLocalDirectory, execDir, 'script-sub.js');222- existsSpy.mockImplementation((path) => path === localPath);214+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);215 program.parse(['node', path.resolve(gLocalDirectory, 'script'), 'sub']);216 225- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);217+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);218 });219 228- test('when script arg and absolute executableDir then spawn absolute script-sub.js', () => {220+ test('when script arg and absolute executableDir then spawn absolute script-sub.js', (t) => {221 const program = new commander.Command();222 program.command('sub', 'executable description');223 224 const execDir = path.resolve(gLocalDirectory, 'exec-dir');225 program.executableDir(execDir);226 const localPath = path.resolve(execDir, 'script-sub.js');235- existsSpy.mockImplementation((path) => path === localPath);227+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);228 program.parse([229 'node',230 path.resolve(gLocalDirectory, 'script-Dir', 'script'),231 'sub',232 ]);233 242- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);234+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);235 });236 245- test('when script arg is link and and link-sub relative to link target then spawn local link-sub', () => {237+ test('when script arg is link and and link-sub relative to link target then spawn local link-sub', (t) => {238 const program = new commander.Command();239 program.command('sub', 'executable description');240 241 const linkPath = path.resolve(gLocalDirectory, 'link', 'link');2 unmodified lines244 gLocalDirectory,245 'script',246 'link-sub.js',247 );256- const realPathSyncSpy = jest257- .spyOn(fs, 'realpathSync')258- .mockImplementation((path) => {259- return path === linkPath ? scriptPath : linkPath;260- });261- existsSpy.mockImplementation((path) => path === scriptSubPath);248+ t.mock.method(fs, 'realpathSync', (path) => {249+ return path === linkPath ? scriptPath : linkPath;250+ });251+ const { spawnSpy } = makeSpies(t, (path) => path === scriptSubPath);252 program.parse(['node', linkPath, 'sub']);263- realPathSyncSpy.mockRestore();253 265- expect(extractMockSpawnArgs(spawnSpy)).toEqual([scriptSubPath]);254+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [scriptSubPath]);255 });256 268- test('when name pm and script arg and relative executableFile then spawn local exec.js', () => {257+ test('when name pm and script arg and relative executableFile then spawn local exec.js', (t) => {258 const program = new commander.Command('pm');259 const localPath = path.join('relative', 'exec.js');260 const absolutePath = path.resolve(gLocalDirectory, localPath);261 program.command('sub', 'executable description', {262 executableFile: localPath,263 });264 276- existsSpy.mockImplementation((path) => path === absolutePath);265+ const { spawnSpy } = makeSpies(t, (path) => path === absolutePath);266 program.parse([267 'node',268 path.resolve(gLocalDirectory, 'script.js'),269 'sub',270 ]);271 283- expect(extractMockSpawnArgs(spawnSpy)).toEqual([absolutePath]);272+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [absolutePath]);273 });274 286- test('when name pm and script arg and absolute executableFile then spawn local exec.js', () => {275+ test('when name pm and script arg and absolute executableFile then spawn local exec.js', (t) => {276 const program = new commander.Command('pm');277 const localPath = path.resolve(gLocalDirectory, 'absolute', 'exec.js');278 program.command('sub', 'executable description', {279 executableFile: localPath,280 });281 293- existsSpy.mockImplementation((path) => path === localPath);282+ const { spawnSpy } = makeSpies(t, (path) => path === localPath);283 program.parse([284 'node',285 path.resolve(gLocalDirectory, 'script.js'),286 'sub',287 ]);288 300- expect(extractMockSpawnArgs(spawnSpy)).toEqual([localPath]);289+ assert.deepEqual(extractMockSpawnArgs(spawnSpy), [localPath]);290 });291 });292 293 describe('search for local file', () => {305- test('when script arg then search for local script-sub.js, .ts, .tsx, .mpjs, .cjs', () => {306- existsSpy.mockImplementation((path) => false);294+ test('when script arg then search for local script-sub.js, .ts, .tsx, .mpjs, .cjs', (t) => {295+ const { existsSpy } = makeSpies(t, () => false);296 const program = new commander.Command();297 program._checkForMissingExecutable = () => {}; // suppress error, call mocked spawn298 program.command('sub', 'executable description');299 const scriptPath = path.resolve(gLocalDirectory, 'script');300 program.parse(['node', scriptPath, 'sub']);301 const sourceExt = ['.js', '.ts', '.tsx', '.mjs', '.cjs'];302 sourceExt.forEach((ext) => {314- expect(existsSpy).toHaveBeenCalledWith(315- path.resolve(gLocalDirectory, `script-sub${ext}`),303+ const expectedPath = path.resolve(gLocalDirectory, `script-sub${ext}`);304+ const wasCalled = existsSpy.mock.calls.some(305+ (call) => call.arguments[0] === expectedPath,306 );307+ assert.equal(308+ wasCalled,309+ true,310+ `Expected existsSpy to be called with ${expectedPath}`,311+ );312 });313 });314 });315 });modified:tests/command.executableSubcommand.signals.test.js+26 added-22 removed
1 const childProcess = require('child_process');2 const path = require('path');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 const pmPath = path.join(__dirname, 'fixtures', 'pm');7 8 // Disabling some tests on Windows as:2 unmodified lines11 const describeOrSkipOnWindows =12 process.platform === 'win32' ? describe.skip : describe;13 14 describeOrSkipOnWindows('signals', () => {13- test.each(['SIGINT', 'SIGHUP', 'SIGTERM', 'SIGUSR1', 'SIGUSR2'])(14- 'when program sent %s then executableSubcommand sent signal too',15- (signal, done) => {16- // Spawn program. The listen subcommand waits for a signal and writes the name of the signal to stdout.17- const proc = childProcess.spawn(pmPath, ['listen'], {});15+ describe('signal forwarding tests', () => {16+ const signals = ['SIGINT', 'SIGHUP', 'SIGTERM', 'SIGUSR1', 'SIGUSR2'];17+ for (const signal of signals) {18+ test(`when program sent ${signal} then executableSubcommand sent signal too`, (t, done) => {19+ // Spawn program. The listen subcommand waits for a signal and writes the name of the signal to stdout.20+ const proc = childProcess.spawn(pmPath, ['listen'], {});21 19- let processOutput = '';20- proc.stdout.on('data', (data) => {21- if (processOutput.length === 0) {22- // Send signal to program.23- proc.kill(`${signal}`);24- }25- processOutput += data.toString();22+ let processOutput = '';23+ proc.stdout.on('data', (data) => {24+ if (processOutput.length === 0) {25+ // Send signal to program.26+ proc.kill(`${signal}`);27+ }28+ processOutput += data.toString();29+ });30+ proc.on('close', (code) => {31+ // Check the child subcommand received the signal too.32+ assert.equal(processOutput, `Listening for signal...${signal}`);33+ done();34+ });35 });27- proc.on('close', (code) => {28- // Check the child subcommand received the signal too.29- expect(processOutput).toBe(`Listening for signal...${signal}`);30- done();31- });32- },33- );36+ }37+ });38 39 test('when executable subcommand sent signal then program exit code is non-zero', () => {40 const { status } = childProcess.spawnSync(pmPath, ['terminate'], {});37- expect(status).toBeGreaterThan(0);41+ assert.equal(status > 0, true);42 });43 44 test('when command has exitOverride and executable subcommand sent signal then exit code is non-zero', () => {45 const { status } = childProcess.spawnSync(46 pmPath,47 ['exit-override', 'terminate'],48 {},49 );46- expect(status).toBeGreaterThan(0);50+ assert.equal(status > 0, true);51 });52 53 // Not a signal test, but closely related code so adding here.54 test('when command has exitOverride and executable subcommand fails then program exit code is subcommand exit code', () => {1 unmodified line56 pmPath,57 ['exit-override', 'fail'],58 {},59 );56- expect(status).toEqual(42);60+ assert.equal(status, 42);61 });62 });modified:tests/command.executableSubcommand.test.js+14 added-16 removed
1-const commander = require('../');1+const { createTestCommand } = require('./testHelpers');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Executable subcommand tests that didn't fit in elsewhere.6 7 // This is the default behaviour when no default command and no action handlers6-test('when no command specified and executable then display help', () => {7- // Optional. Suppress normal output to keep test output clean.8- const writeSpy = jest9- .spyOn(process.stderr, 'write')10- .mockImplementation(() => {});11- const program = new commander.Command();12- program13- .exitOverride((err) => {14- throw err;15- })16- .command('install', 'install description');17- expect(() => {18- program.parse(['node', 'test']);19- }).toThrow('(outputHelp)');20- writeSpy.mockClear();8+test('when no command specified and executable then display help', (t) => {9+ const program = createTestCommand();10+ program.command('install', 'install description');11+ assert.throws(12+ () => {13+ program.parse(['node', 'test']);14+ },15+ {16+ code: 'commander.help',17+ },18+ );19 });modified:tests/command.exitOverride.test.js+59 added-62 removed
1 const commander = require('../');2 const path = require('path');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');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.10 9-/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "expectCommanderError"] }] */10-11 function expectCommanderError(err, exitCode, code, message) {12- expect(err).toBeInstanceOf(commander.CommanderError);13- expect(err.exitCode).toBe(exitCode);14- expect(err.code).toBe(code);15- expect(err.message).toBe(message);12+ assert(err instanceof commander.CommanderError);13+ assert.equal(err.exitCode, exitCode);14+ assert.equal(err.code, code);15+ assert.equal(err.message, message);16 }17 18 describe('.exitOverride and error details', () => {19 // Use internal knowledge to suppress output to keep test output clean.20- let stderrSpy;20 22- beforeAll(() => {23- stderrSpy = jest24- .spyOn(process.stderr, 'write')25- .mockImplementation(() => {});26- });27-28- afterEach(() => {29- stderrSpy.mockClear();30- });31-32- afterAll(() => {33- stderrSpy.mockRestore();34- });35-36- test('when specify unknown program option then throw CommanderError', () => {21+ test('when specify unknown program option then throw CommanderError', (t) => {22+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});23 const program = new commander.Command();24 program.exitOverride();25 26 let caughtErr;2 unmodified lines29 } catch (err) {30 caughtErr = err;31 }32 47- expect(stderrSpy).toHaveBeenCalled();33+ assert(stderrSpy.mock.callCount() > 0);34 expectCommanderError(35 caughtErr,36 1,37 'commander.unknownOption',38 "error: unknown option '-m'",39 );40 });41 56- test('when specify unknown command then throw CommanderError', () => {42+ test('when specify unknown command then throw CommanderError', (t) => {43+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});44 const program = new commander.Command();45 program.name('prog').exitOverride().command('sub');46 47 let caughtErr;2 unmodified lines50 } catch (err) {51 caughtErr = err;52 }53 67- expect(stderrSpy).toHaveBeenCalled();54+ assert(stderrSpy.mock.callCount() > 0);55 expectCommanderError(56 caughtErr,57 1,58 'commander.unknownCommand',1 unmodified line60 );61 });62 63 // Same error as above, but with custom handler.77- test('when supply custom handler then throw custom error', () => {64+ test('when supply custom handler then throw custom error', (t) => {65+ t.mock.method(process.stderr, 'write', () => {});66 const customError = new commander.CommanderError(67 123,68 'custom-code',69 'custom-message',17 unmodified lines87 customError.message,88 );89 });90 103- test('when specify option without required value then throw CommanderError', () => {91+ test('when specify option without required value then throw CommanderError', (t) => {92+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});93 const optionFlags = '-p, --pepper <type>';94 const program = new commander.Command();95 program.exitOverride().option(optionFlags, 'add pepper');96 3 unmodified lines100 } catch (err) {101 caughtErr = err;102 }103 115- expect(stderrSpy).toHaveBeenCalled();104+ assert(stderrSpy.mock.callCount() > 0);105 expectCommanderError(106 caughtErr,107 1,108 'commander.optionMissingArgument',109 `error: option '${optionFlags}' argument missing`,110 );111 });112 124- test('when specify command without required argument then throw CommanderError', () => {113+ test('when specify command without required argument then throw CommanderError', (t) => {114+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});115 const program = new commander.Command();116 program117 .exitOverride()118 .command('compress <arg-name>')5 unmodified lines124 } catch (err) {125 caughtErr = err;126 }127 138- expect(stderrSpy).toHaveBeenCalled();128+ assert(stderrSpy.mock.callCount() > 0);129 expectCommanderError(130 caughtErr,131 1,132 'commander.missingArgument',133 "error: missing required argument 'arg-name'",134 );135 });136 147- test('when specify program without required argument and no action handler then throw CommanderError', () => {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', () => {});139 const program = new commander.Command();140 program.exitOverride().argument('<arg-name>');141 142 let caughtErr;2 unmodified lines145 } catch (err) {146 caughtErr = err;147 }148 158- expect(stderrSpy).toHaveBeenCalled();149+ assert(stderrSpy.mock.callCount() > 0);150 expectCommanderError(151 caughtErr,152 1,153 'commander.missingArgument',154 "error: missing required argument 'arg-name'",155 );156 });157 167- test('when specify excess argument then throw CommanderError', () => {158+ test('when specify excess argument then throw CommanderError', (t) => {159+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});160 const program = new commander.Command();161 program162 .exitOverride()163 .allowExcessArguments(false)5 unmodified lines169 } catch (err) {170 caughtErr = err;171 }172 181- expect(stderrSpy).toHaveBeenCalled();173+ assert(stderrSpy.mock.callCount() > 0);174 expectCommanderError(175 caughtErr,176 1,177 'commander.excessArguments',178 'error: too many arguments. Expected 0 arguments but got 1: excess.',179 );180 });181 190- test('when specify command with excess argument then throw CommanderError', () => {182+ test('when specify command with excess argument then throw CommanderError', (t) => {183+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});184 const program = new commander.Command();185 program186 .exitOverride()187 .command('speak')6 unmodified lines194 } catch (err) {195 caughtErr = err;196 }197 205- expect(stderrSpy).toHaveBeenCalled();198+ assert(stderrSpy.mock.callCount() > 0);199 expectCommanderError(200 caughtErr,201 1,202 'commander.excessArguments',203 "error: too many arguments for 'speak'. Expected 0 arguments but got 1: excess.",204 );205 });206 214- test('when specify --help then throw CommanderError', () => {215- const writeSpy = jest216- .spyOn(process.stdout, 'write')217- .mockImplementation(() => {});207+ test('when specify --help then throw CommanderError', (t) => {208+ t.mock.method(process.stderr, 'write', () => {});209 const program = new commander.Command();210 program.exitOverride();211 212 let caughtErr;8 unmodified lines221 0,222 'commander.helpDisplayed',223 '(outputHelp)',224 );234- writeSpy.mockRestore();225 });226 237- test('when executable subcommand and no command specified then throw CommanderError', () => {227+ test('when executable subcommand and no command specified then throw CommanderError', (t) => {228+ const stderrSpy = t.mock.method(process.stderr, 'write', () => {});229 const program = new commander.Command();230 program.exitOverride().command('compress', 'compress description');231 232 let caughtErr;5 unmodified lines238 239 expectCommanderError(caughtErr, 1, 'commander.help', '(outputHelp)');240 });241 251- test('when specify --version then throw CommanderError', () => {252- const stdoutSpy = jest253- .spyOn(process.stdout, 'write')254- .mockImplementation(() => {});242+ test('when specify --version then throw CommanderError', (t) => {243+ t.mock.method(process.stderr, 'write', () => {});244 const myVersion = '1.2.3';245 const program = new commander.Command();246 program.exitOverride().version(myVersion);247 4 unmodified lines252 caughtErr = err;253 }254 255 expectCommanderError(caughtErr, 0, 'commander.version', myVersion);267- stdoutSpy.mockRestore();256 });257 258 test('when executableSubcommand succeeds then call exitOverride', async () => {271- expect.hasAssertions();259 const pm = path.join(__dirname, 'fixtures/pm');260 const program = new commander.Command();261 await new Promise((resolve) => {262 program10 unmodified lines273 program.parse(['node', pm, 'silent']);274 });275 });276 290- test('when mandatory program option missing then throw CommanderError', () => {277+ test('when mandatory program option missing then throw CommanderError', (t) => {278+ t.mock.method(process.stderr, 'write', () => {});279 const optionFlags = '-p, --pepper <type>';280 const program = new commander.Command();281 program.exitOverride().requiredOption(optionFlags, 'add pepper');282 11 unmodified lines294 `error: required option '${optionFlags}' not specified`,295 );296 });297 310- test('when option argument not in choices then throw CommanderError', () => {298+ test('when option argument not in choices then throw CommanderError', (t) => {299+ t.mock.method(process.stderr, 'write', () => {});300 const optionFlags = '--colour <shade>';301 const program = new commander.Command();302 program303 .exitOverride()13 unmodified lines317 "error: option '--colour <shade>' argument 'green' is invalid. Allowed choices are red, blue.",318 );319 });320 332- test('when command argument not in choices then throw CommanderError', () => {321+ test('when command argument not in choices then throw CommanderError', (t) => {322+ t.mock.method(process.stderr, 'write', () => {});323 const program = new commander.Command();324 program325 .exitOverride()326 .addArgument(new commander.Argument('<shade>').choices(['red', 'blue']))13 unmodified lines340 "error: command-argument value 'green' is invalid for argument 'shade'. Allowed choices are red, blue.",341 );342 });343 354- test('when custom processing for option throws InvalidArgumentError then catch CommanderError', () => {344+ test('when custom processing for option throws InvalidArgumentError then catch CommanderError', (t) => {345+ t.mock.method(process.stderr, 'write', () => {});346 function justSayNo(value) {347 throw new commander.InvalidArgumentError('NO');348 }349 const optionFlags = '--colour <shade>';14 unmodified lines364 "error: option '--colour <shade>' argument 'green' is invalid. NO",365 );366 });367 377- test('when custom processing for argument throws InvalidArgumentError then catch CommanderError', () => {368+ test('when custom processing for argument throws InvalidArgumentError then catch CommanderError', (t) => {369+ t.mock.method(process.stderr, 'write', () => {});370 function justSayNo(value) {371 throw new commander.InvalidArgumentError('NO');372 }373 const program = new commander.Command();16 unmodified lines390 "error: command-argument value 'green' is invalid for argument 'n'. NO",391 );392 });393 402- test('when has conflicting option then throw CommanderError', () => {394+ test('when has conflicting option then throw CommanderError', (t) => {395+ t.mock.method(process.stderr, 'write', () => {});396 const program = new commander.Command();397 program398 .exitOverride()399 .addOption(new commander.Option('--silent'))13 unmodified lines413 "error: option '--debug' cannot be used with option '--silent'",414 );415 });416 424- test('when call error() then throw CommanderError', () => {417+ test('when call error() then throw CommanderError', (t) => {418+ t.mock.method(process.stderr, 'write', () => {});419 const program = new commander.Command();420 program.exitOverride();421 422 let caughtErr;6 unmodified lines429 expectCommanderError(caughtErr, 1, 'commander.error', 'message');430 });431 });432 439-test('when no override and error then exit(1)', () => {440- const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});433+test('when no override and error then exit(1)', (t) => {434+ const exitSpy = t.mock.method(process, 'exit', () => {});435 const program = new commander.Command();436 program.configureOutput({ outputError: () => {} });437 program.parse(['--unknownOption'], { from: 'user' });444- expect(exitSpy).toHaveBeenCalledWith(1);445- exitSpy.mockRestore();438+ assert(exitSpy.mock.callCount() >= 1);439+ assert.deepEqual(exitSpy.mock.calls[0].arguments, [1]);440 });441 442 test('when custom processing throws custom error then throw custom error', () => {443 function justSayNo(value) {3 unmodified lines447 program448 .exitOverride()449 .option('-s, --shade <value>', 'specify shade', justSayNo);450 457- expect(() => {458- program.parse(['--shade', 'green'], { from: 'user' });459- }).toThrow('custom');451+ assert.throws(452+ () => {453+ program.parse(['--shade', 'green'], { from: 'user' });454+ },455+ { message: 'custom' },456+ );457 });modified:tests/command.help.test.js+86 added-83 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test } = require('node:test');4+const assert = require('node:assert/strict');5 6 // Testing various help incantations.7 //8 // Note there are also specific help tests included in many of the feature tests,14 unmodified lines23 `;24 25 program.name('test');26 const helpInformation = program.helpInformation();24- expect(helpInformation).toBe(expectedHelpInformation);27+ assert.equal(helpInformation, expectedHelpInformation);28 });29 30 test('when use .description for command then help includes description', () => {31 const program = new commander.Command();32 program.command('simple-command').description('custom-description');33 program._help = 'test';34 const helpInformation = program.helpInformation();32- expect(helpInformation).toMatch(/simple-command +custom-description/);35+ assert.match(helpInformation, /simple-command +custom-description/);36 });37 35-test('when call .help then exit', () => {36- // Optional. Suppress normal output to keep test output clean.37- const writeSpy = jest38- .spyOn(process.stdout, 'write')39- .mockImplementation(() => {});40- const program = new commander.Command();41- program.exitOverride();42- expect(() => {43- program.help();44- }).toThrow('(outputHelp)');45- writeSpy.mockClear();38+test('when call .help then exit', (t) => {39+ const program = createTestCommand();40+ assert.throws(41+ () => {42+ program.help();43+ },44+ { message: '(outputHelp)' },45+ );46 });47 48-test('when specify --help then exit', () => {49- // Optional. Suppress normal output to keep test output clean.50- const writeSpy = jest51- .spyOn(process.stdout, 'write')52- .mockImplementation(() => {});53- const program = new commander.Command();54- program.exitOverride();55- expect(() => {56- program.parse(['node', 'test', '--help']);57- }).toThrow('(outputHelp)');58- writeSpy.mockClear();48+test('when specify --help then exit', (t) => {49+ const program = createTestCommand();50+ assert.throws(51+ () => {52+ program.parse(['node', 'test', '--help']);53+ },54+ { message: '(outputHelp)' },55+ );56 });57 61-test('when call help(cb) then display cb output and exit', () => {58+test('when call help(cb) then display cb output and exit', (t) => {59 // Using spy to detect custom output63- const writeSpy = jest64- .spyOn(process.stdout, 'write')65- .mockImplementation(() => {});60+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});61 const helpReplacement = 'reformatted help';62 const program = new commander.Command();63 program.exitOverride();69- expect(() => {70- program.help((helpInformation) => {71- return helpReplacement;72- });73- }).toThrow('(outputHelp)');74- expect(writeSpy).toHaveBeenCalledWith(helpReplacement);75- writeSpy.mockClear();64+ assert.throws(65+ () => {66+ program.help((helpInformation) => {67+ return helpReplacement;68+ });69+ },70+ { message: '(outputHelp)' },71+ );72+ assert.equal(writeSpy.mock.callCount(), 1);73+ assert.deepEqual(writeSpy.mock.calls[0].arguments, [helpReplacement]);74 });75 78-test('when call outputHelp(cb) then display cb output', () => {76+test('when call outputHelp(cb) then display cb output', (t) => {77 // Using spy to detect custom output80- const writeSpy = jest81- .spyOn(process.stdout, 'write')82- .mockImplementation(() => {});78+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});79 const helpReplacement = 'reformatted help';80 const program = new commander.Command();81 program.outputHelp((helpInformation) => {82 return helpReplacement;83 });88- expect(writeSpy).toHaveBeenCalledWith(helpReplacement);89- writeSpy.mockClear();84+ assert.equal(writeSpy.mock.callCount(), 1);85+ assert.deepEqual(writeSpy.mock.calls[0].arguments, [helpReplacement]);86 });87 88 test('when call deprecated outputHelp(cb) with wrong callback return type then throw', () => {89 const program = new commander.Command();94- expect(() => {90+ assert.throws(() => {91 program.outputHelp((helpInformation) => 3);96- }).toThrow();92+ });93 });94 95 test('when command sets deprecated noHelp then not displayed in helpInformation', () => {96 const program = new commander.Command();97 program.command('secret', 'secret description', { noHelp: true });98 const helpInformation = program.helpInformation();103- expect(helpInformation).not.toMatch('secret');99+ assert(!helpInformation.includes('secret'));100 });101 102 test('when command sets hidden then not displayed in helpInformation', () => {103 const program = new commander.Command();104 program.command('secret', 'secret description', { hidden: true });105 const helpInformation = program.helpInformation();110- expect(helpInformation).not.toMatch('secret');106+ assert(!helpInformation.includes('secret'));107 });108 109 test('when addCommand with hidden:true then not displayed in helpInformation', () => {110 const secretCmd = new commander.Command('secret');111 112 const program = new commander.Command();113 program.addCommand(secretCmd, { hidden: true });114 const helpInformation = program.helpInformation();119- expect(helpInformation).not.toMatch('secret');115+ assert(!helpInformation.includes('secret'));116 });117 118 test('when help short flag masked then not displayed in helpInformation', () => {119 const program = new commander.Command();120 program.option('-h, --host', 'select host');121 const helpInformation = program.helpInformation();126- expect(helpInformation).not.toMatch(/\W-h\W.*display help/);122+ assert(!/\W-h\W.*display help/.test(helpInformation));123 });124 125 test('when both help flags masked then not displayed in helpInformation', () => {126 const program = new commander.Command();127 program.option('-h, --help', 'custom');128 const helpInformation = program.helpInformation();133- expect(helpInformation).not.toMatch('display help');129+ assert(!helpInformation.includes('display help'));130 });131 136-test('when call .help then output on stdout', () => {137- const writeSpy = jest138- .spyOn(process.stdout, 'write')139- .mockImplementation(() => {});132+test('when call .help then output on stdout', (t) => {133+ const writeSpy = t.mock.method(process.stdout, 'write', () => {});134 const program = new commander.Command();135 program.exitOverride();142- expect(() => {143- program.help();144- }).toThrow('(outputHelp)');145- expect(writeSpy).toHaveBeenCalledWith(program.helpInformation());146- writeSpy.mockClear();136+ assert.throws(137+ () => {138+ program.help();139+ },140+ { message: '(outputHelp)' },141+ );142+ assert.equal(writeSpy.mock.callCount(), 1);143+ assert.deepEqual(writeSpy.mock.calls[0].arguments, [144+ program.helpInformation(),145+ ]);146 });147 149-test('when call .help with { error: true } then output on stderr', () => {150- const writeSpy = jest151- .spyOn(process.stderr, 'write')152- .mockImplementation(() => {});148+test('when call .help with { error: true } then output on stderr', (t) => {149+ const writeSpy = t.mock.method(process.stderr, 'write', () => {});150 const program = new commander.Command();151 program.exitOverride();155- expect(() => {156- program.help({ error: true });157- }).toThrow('(outputHelp)');158- expect(writeSpy).toHaveBeenCalledWith(program.helpInformation());159- writeSpy.mockClear();152+ assert.throws(153+ () => {154+ program.help({ error: true });155+ },156+ { message: '(outputHelp)' },157+ );158+ assert.equal(writeSpy.mock.callCount(), 1);159+ assert.deepEqual(writeSpy.mock.calls[0].arguments, [160+ program.helpInformation(),161+ ]);162 });163 164 test('when no options then Options not included in helpInformation', () => {165 const program = new commander.Command();166 // No custom options, no version option, no help option167 program.helpOption(false);168 const helpInformation = program.helpInformation();167- expect(helpInformation).not.toMatch('Options');169+ assert(!helpInformation.includes('Options'));170 });171 172 test('when negated option then option included in helpInformation', () => {173 const program = new commander.Command();174 program.option('-C, --no-colour', 'colourless');175 const helpInformation = program.helpInformation();174- expect(helpInformation).toMatch('--no-colour');175- expect(helpInformation).toMatch('colourless');176+ assert(helpInformation.includes('--no-colour'));177+ assert(helpInformation.includes('colourless'));178 });179 180 test('when option.hideHelp() then option not included in helpInformation', () => {181 const program = new commander.Command();182 program.addOption(183 new commander.Option('-s,--secret', 'secret option').hideHelp(),184 );185 const helpInformation = program.helpInformation();184- expect(helpInformation).not.toMatch('secret');186+ assert(!helpInformation.includes('secret'));187 });188 189 test('when option.hideHelp(true) then option not included in helpInformation', () => {190 const program = new commander.Command();191 program.addOption(192 new commander.Option('-s,--secret', 'secret option').hideHelp(true),193 );194 const helpInformation = program.helpInformation();193- expect(helpInformation).not.toMatch('secret');195+ assert(!helpInformation.includes('secret'));196 });197 198 test('when option.hideHelp(false) then option included in helpInformation', () => {199 const program = new commander.Command();200 program.addOption(201 new commander.Option('-s,--secret', 'secret option').hideHelp(false),202 );203 const helpInformation = program.helpInformation();202- expect(helpInformation).toMatch('secret');204+ assert(helpInformation.includes('secret'));205 });206 207 test('when option has default value then default included in helpInformation', () => {208 const program = new commander.Command();209 program.option('-p, --port <portNumber>', 'port number', 80);210 const helpInformation = program.helpInformation();209- expect(helpInformation).toMatch('(default: 80)');211+ assert(helpInformation.includes('(default: 80)'));212 });213 214 test('when option has default value description then default description included in helpInformation', () => {215 const program = new commander.Command();3 unmodified lines219 'home',220 ),221 );222 const helpInformation = program.helpInformation();221- expect(helpInformation).toMatch('(default: home)');223+ assert(helpInformation.includes('(default: home)'));224 });225 226 test('when option has choices then choices included in helpInformation', () => {227 const program = new commander.Command();228 program.addOption(229 new commander.Option('-c, --colour <colour>').choices(['red', 'blue']),230 );231 const helpInformation = program.helpInformation();230- expect(helpInformation).toMatch('(choices: "red", "blue")');232+ assert(helpInformation.includes('(choices: "red", "blue")'));233 });234 235 test('when option has choices and default then both included in helpInformation', () => {236 const program = new commander.Command();2 unmodified lines239 .choices(['red', 'blue'])240 .default('red'),241 );242 const helpInformation = program.helpInformation();241- expect(helpInformation).toMatch('(choices: "red", "blue", default: "red")');243+ assert(helpInformation.includes('(choices: "red", "blue", default: "red")'));244 });245 246 test('when argument then included in helpInformation', () => {247 const program = new commander.Command();248 program.name('foo').argument('<file>');249 const helpInformation = program.helpInformation();248- expect(helpInformation).toMatch('Usage: foo [options] <file>');250+ assert(helpInformation.includes('Usage: foo [options] <file>'));251 });252 253 test('when argument described then included in helpInformation', () => {254 const program = new commander.Command();255 program.argument('<file>', 'input source').helpOption(false);256 const helpInformation = program.helpInformation();255- expect(helpInformation).toMatch(/Arguments:\n +file +input source/);257+ assert.match(helpInformation, /Arguments:\n +file +input source/);258 });259 260 test('when argument described with default then included in helpInformation', () => {261 const program = new commander.Command();262 program.argument('[file]', 'input source', 'test.txt').helpOption(false);263 const helpInformation = program.helpInformation();262- expect(helpInformation).toMatch(264+ assert.match(265+ helpInformation,266 /Arguments:\n +file +input source \(default: "test.txt"\)/,267 );268 });269 3 unmodified lines273 .arguments('<file>')274 .helpOption(false)275 .description('description', { file: 'input source' });276 const helpInformation = program.helpInformation();274- expect(helpInformation).toMatch(/Arguments:\n +file +input source/);277+ assert.match(helpInformation, /Arguments:\n +file +input source/);278 });279 280 test('when arguments described in deprecated way and empty description then arguments still included in helpInformation', () => {281 const program = new commander.Command();1 unmodified line283 .arguments('<file>')284 .helpOption(false)285 .description('', { file: 'input source' });286 const helpInformation = program.helpInformation();284- expect(helpInformation).toMatch(/Arguments:\n +file +input source/);287+ assert.match(helpInformation, /Arguments:\n +file +input source/);288 });289 290 test('when argument has choices then choices included in helpInformation', () => {291 const program = new commander.Command();3 unmodified lines295 'blue',296 ]),297 );298 const helpInformation = program.helpInformation();296- expect(helpInformation).toMatch('(choices: "red", "blue")');299+ assert(helpInformation.includes('(choices: "red", "blue")'));300 });301 302 test('when argument has choices and default then both included in helpInformation', () => {303 const program = new commander.Command();2 unmodified lines306 .choices(['red', 'blue'])307 .default('red'),308 );309 const helpInformation = program.helpInformation();307- expect(helpInformation).toMatch('(choices: "red", "blue", default: "red")');310+ assert(helpInformation.includes('(choices: "red", "blue", default: "red")'));311 });modified:tests/command.helpCommand.test.js+50 added-61 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 describe('help command listed in helpInformation', () => {7 test('when program has no subcommands then no automatic help command', () => {8 const program = new commander.Command();9 const helpInformation = program.helpInformation();7- expect(helpInformation).not.toMatch(/help \[command\]/);10+ assert.doesNotMatch(helpInformation, /help \[command\]/);11 });12 13 test('when program has no subcommands and add help command then has help command', () => {14 const program = new commander.Command();15 program.addHelpCommand(true);16 const helpInformation = program.helpInformation();14- expect(helpInformation).toMatch(/help \[command\]/);17+ assert.match(helpInformation, /help \[command\]/);18 });19 20 test('when program has subcommands then has automatic help command', () => {21 const program = new commander.Command();22 program.command('foo');23 const helpInformation = program.helpInformation();21- expect(helpInformation).toMatch(/help \[command\]/);24+ assert.match(helpInformation, /help \[command\]/);25 });26 27 test('when program has subcommands and specify only unknown option then display help', () => {25- const program = new commander.Command();26- program27- .configureHelp({ formatHelp: () => '' })28- .exitOverride()29- .allowUnknownOption()30- .command('foo');31- let caughtErr;32- try {33- program.parse(['--unknown'], { from: 'user' });34- } catch (err) {35- caughtErr = err;36- }37- expect(caughtErr.code).toEqual('commander.help');28+ const program = createTestCommand();29+ program.allowUnknownOption().command('foo');30+ assert.throws(31+ () => {32+ program.parse(['--unknown'], { from: 'user' });33+ },34+ {35+ code: 'commander.help',36+ },37+ );38 });39 40 test('when program has subcommands and suppress help command then no help command', () => {41 const program = new commander.Command();42 program.addHelpCommand(false);43 program.command('foo');44 const helpInformation = program.helpInformation();45- expect(helpInformation).not.toMatch(/help \[command\]/);45+ assert.doesNotMatch(helpInformation, /help \[command\]/);46 });47 48 test('when add custom help command then custom help command', () => {49 const program = new commander.Command();50 program.addHelpCommand('myHelp', 'help description');51 const helpInformation = program.helpInformation();52- expect(helpInformation).toMatch(/myHelp +help description/);52+ assert.match(helpInformation, /myHelp +help description/);53 });54 });55 56 describe('help command processed on correct command', () => {57- // Use internal knowledge to suppress output to keep test output clean.58- let writeErrorSpy;59- let writeSpy;57+ function makeCommand() {58+ const program = new commander.Command();59+ program.configureOutput({60+ writeOut: () => {},61+ writeErr: () => {},62+ });63 61- beforeAll(() => {62- writeErrorSpy = jest63- .spyOn(process.stderr, 'write')64- .mockImplementation(() => {});65- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});66- });64+ return program;65+ }66 68- afterEach(() => {69- writeErrorSpy.mockClear();70- writeSpy.mockClear();71- });72-73- afterAll(() => {74- writeErrorSpy.mockRestore();75- writeSpy.mockRestore();76- });77-67 test('when "program help" then program', () => {79- const program = new commander.Command();68+ const program = makeCommand();69 program.exitOverride();70 program.command('sub1');71 program.exitOverride(() => {72 throw new Error('program');73 });85- expect(() => {74+ assert.throws(() => {75 program.parse('node test.js help'.split(' '));87- }).toThrow('program');76+ }, /program/);77 });78 79 test('when "program help unknown" then program', () => {91- const program = new commander.Command();80+ const program = makeCommand();81 program.exitOverride();82 program.command('sub1');83 program.exitOverride(() => {84 throw new Error('program');85 });97- expect(() => {86+ assert.throws(() => {87 program.parse('node test.js help unknown'.split(' '));99- }).toThrow('program');88+ }, /program/);89 });90 91 test('when "program help sub1" then sub1', () => {103- const program = new commander.Command();92+ const program = makeCommand();93 program.exitOverride();94 const sub1 = program.command('sub1');95 sub1.exitOverride(() => {96 throw new Error('sub1');97 });109- expect(() => {98+ assert.throws(() => {99 program.parse('node test.js help sub1'.split(' '));111- }).toThrow('sub1');100+ }, /sub1/);101 });102 103 test('when "program sub1 help sub2" then sub2', () => {115- const program = new commander.Command();104+ const program = makeCommand();105 program.exitOverride();106 const sub1 = program.command('sub1');107 const sub2 = sub1.command('sub2');108 sub2.exitOverride(() => {109 throw new Error('sub2');110 });122- expect(() => {111+ assert.throws(() => {112 program.parse('node test.js sub1 help sub2'.split(' '));124- }).toThrow('sub2');113+ }, /sub2/);114 });115 116 test('when default command and "program help" then program', () => {128- const program = new commander.Command();117+ const program = makeCommand();118 program.exitOverride();119 program.command('sub1', { isDefault: true });120 program.exitOverride(() => {121 throw new Error('program');122 });134- expect(() => {123+ assert.throws(() => {124 program.parse('node test.js help'.split(' '));136- }).toThrow('program');125+ }, /program/);126 });127 128 test('when no long help flag then "help sub" works', () => {140- const program = new commander.Command();129+ const program = makeCommand();130 program.exitOverride();131 program.helpOption('-H');132 const sub = program.command('sub');133 // Patch help for easy way to check called.134 sub.help = () => {135 throw new Error('sub help');136 };148- expect(() => {137+ assert.throws(() => {138 program.parse(['help', 'sub'], { from: 'user' });150- }).toThrow('sub help');139+ }, /sub help/);140 });141 142 test('when no help options in sub then "help sub" works', () => {154- const program = new commander.Command();143+ const program = makeCommand();144 program.exitOverride();145 const sub = program.command('sub').helpOption(false);146 // Patch help for easy way to check called.147 sub.help = () => {148 throw new Error('sub help');149 };161- expect(() => {150+ assert.throws(() => {151 program.parse(['help', 'sub'], { from: 'user' });163- }).toThrow('sub help');152+ }, /sub help/);153 });154 155 test('when different help options in sub then "help sub" works', () => {167- const program = new commander.Command();156+ const program = makeCommand();157 program.exitOverride();158 const sub = program.command('sub');159 program.helpOption('-h, --help');160 sub.helpOption('-a, --assist');161 // Patch help for easy way to check called.162 sub.help = () => {163 throw new Error('sub help');164 };176- expect(() => {165+ assert.throws(() => {166 program.parse(['help', 'sub'], { from: 'user' });178- }).toThrow('sub help');167+ }, /sub help/);168 });169 });modified:tests/command.helpOption.test.js+72 added-79 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 describe('helpOption', () => {4- let writeSpy;5- let writeErrorSpy;6-7- beforeAll(() => {8- // Optional. Suppress expected output to keep test output clean.9- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});10- writeErrorSpy = jest11- .spyOn(process.stderr, 'write')12- .mockImplementation(() => {});7+ test('when helpOption has custom flags then custom short flag invokes help', (t) => {8+ const program = createTestCommand();9+ program.helpOption('-c,--custom-help', 'custom help output');10+ assert.throws(11+ () => {12+ program.parse(['-c'], { from: 'user' });13+ },14+ { message: '(outputHelp)' },15+ );16 });17 15- afterEach(() => {16- writeSpy.mockClear();17- writeErrorSpy.mockClear();18+ test('when helpOption has custom flags then custom long flag invokes help', (t) => {19+ const program = createTestCommand();20+ program.helpOption('-c,--custom-help', 'custom help output');21+ assert.throws(22+ () => {23+ program.parse(['--custom-help'], { from: 'user' });24+ },25+ { message: '(outputHelp)' },26+ );27 });28 20- afterAll(() => {21- writeSpy.mockRestore();22- writeErrorSpy.mockRestore();29+ test('when helpOption has just custom short flag then custom short flag invokes help', (t) => {30+ const program = createTestCommand();31+ program.helpOption('-c', 'custom help output');32+ assert.throws(33+ () => {34+ program.parse(['-c'], { from: 'user' });35+ },36+ { message: '(outputHelp)' },37+ );38 });39 25- test('when helpOption has custom flags then custom short flag invokes help', () => {26- const program = new commander.Command();27- program.exitOverride().helpOption('-c,--custom-help', 'custom help output');28- expect(() => {29- program.parse(['-c'], { from: 'user' });30- }).toThrow('(outputHelp)');40+ test('when helpOption has just custom long flag then custom long flag invokes help', (t) => {41+ const program = createTestCommand();42+ program.helpOption('--custom-help', 'custom help output');43+ assert.throws(44+ () => {45+ program.parse(['--custom-help'], { from: 'user' });46+ },47+ { message: '(outputHelp)' },48+ );49 });50 33- test('when helpOption has custom flags then custom long flag invokes help', () => {34- const program = new commander.Command();35- program.exitOverride().helpOption('-c,--custom-help', 'custom help output');36- expect(() => {37- program.parse(['--custom-help'], { from: 'user' });38- }).toThrow('(outputHelp)');39- });40-41- test('when helpOption has just custom short flag then custom short flag invokes help', () => {42- const program = new commander.Command();43- program.exitOverride().helpOption('-c', 'custom help output');44- expect(() => {45- program.parse(['-c'], { from: 'user' });46- }).toThrow('(outputHelp)');47- });48-49- test('when helpOption has just custom long flag then custom long flag invokes help', () => {50- const program = new commander.Command();51- program.exitOverride().helpOption('--custom-help', 'custom help output');52- expect(() => {53- program.parse(['--custom-help'], { from: 'user' });54- }).toThrow('(outputHelp)');55- });56-51 test('when helpOption has custom description then helpInformation include custom description', () => {52 const program = new commander.Command();53 program.helpOption('-C,--custom-help', 'custom help output');54 const helpInformation = program.helpInformation();61- expect(helpInformation).toMatch(/-C,--custom-help +custom help output/);55+ assert.match(helpInformation, /-C,--custom-help +custom help output/);56 });57 58 test('when helpOption has just flags then helpInformation includes default description', () => {59 const program = new commander.Command();60 program.helpOption('-C,--custom-help');61 const helpInformation = program.helpInformation();68- expect(helpInformation).toMatch(69- /-C,--custom-help +display help for command/,70- );62+ assert.match(helpInformation, /-C,--custom-help +display help for command/);63 });64 65 test('when helpOption has just description then helpInformation includes default flags', () => {66 const program = new commander.Command();67 program.helpOption(undefined, 'custom help output');68 const helpInformation = program.helpInformation();77- expect(helpInformation).toMatch(/-h, --help +custom help output/);69+ assert.match(helpInformation, /-h, --help +custom help output/);70 });71 72 test('when helpOption(false) then helpInformation does not include --help', () => {73 const program = new commander.Command();74 program.helpOption(false);75 const helpInformation = program.helpInformation();84- expect(helpInformation).not.toMatch('--help');76+ assert(!helpInformation.includes('--help'));77 });78 87- test('when helpOption(false) then --help is an unknown option', () => {88- const program = new commander.Command();89- program.exitOverride().helpOption(false);90- let caughtErr;91- try {92- program.parse(['--help'], { from: 'user' });93- } catch (err) {94- caughtErr = err;95- }96- expect(caughtErr.code).toBe('commander.unknownOption');79+ test('when helpOption(false) then --help is an unknown option', (t) => {80+ const program = createTestCommand();81+ program.helpOption(false);82+ assert.throws(83+ () => {84+ program.parse(['--help'], { from: 'user' });85+ },86+ { code: 'commander.unknownOption' },87+ );88 });89 99- test('when helpOption(false) then -h is an unknown option', () => {100- const program = new commander.Command();101- program.exitOverride().helpOption(false);102- let caughtErr;103- try {104- program.parse(['-h'], { from: 'user' });105- } catch (err) {106- caughtErr = err;107- }108- expect(caughtErr.code).toBe('commander.unknownOption');90+ test('when helpOption(false) then -h is an unknown option', (t) => {91+ const program = createTestCommand();92+ program.helpOption(false);93+ assert.throws(94+ () => {95+ program.parse(['-h'], { from: 'user' });96+ },97+ { code: 'commander.unknownOption' },98+ );99 });100 111- test('when helpOption(false) then unknown command error does not suggest --help', () => {112- const program = new commander.Command();113- program.exitOverride().helpOption(false).command('foo');114- expect(() => {115- program.parse(['UNKNOWN'], { from: 'user' });116- }).toThrow("error: unknown command 'UNKNOWN'");101+ test('when helpOption(false) then unknown command error does not suggest --help', (t) => {102+ const program = createTestCommand();103+ program.helpOption(false).command('foo');104+ assert.throws(105+ () => {106+ program.parse(['UNKNOWN'], { from: 'user' });107+ },108+ { message: "error: unknown command 'UNKNOWN'" },109+ );110 });111 112 test('when helpOption(true) after false then helpInformation does include --help', () => {113 const program = new commander.Command();114 program.helpOption(false);115 program.helpOption(true);116 const helpInformation = program.helpInformation();124- expect(helpInformation).toMatch('--help');117+ assert(helpInformation.includes('--help'));118 });119 120 test('when helpOption(true) after customise then helpInformation still customised', () => {121 const program = new commander.Command();122 program.helpOption('--ASSIST');123 program.helpOption(true);124 const helpInformation = program.helpInformation();132- expect(helpInformation).toMatch('--ASSIST');125+ assert(helpInformation.includes('--ASSIST'));126 });127 });modified:tests/command.hook.test.js+55 added-51 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when hook event wrong then throw', () => {6 const program = new commander.Command();5- expect(() => {7+ assert.throws(() => {8 program.hook('silly', () => {});7- }).toThrow();9+ });10 });11 10-test('when no action then action hooks not called', () => {11- const hook = jest.fn();12+test('when no action then action hooks not called', (t) => {13+ const hook = t.mock.fn();14 const program = new commander.Command();15 program.hook('preAction', hook).hook('postAction', hook);16 program.parse([], { from: 'user' });15- expect(hook).not.toHaveBeenCalled();17+ assert.equal(hook.mock.callCount(), 0);18 });19 20 describe('action hooks with synchronous hooks, order', () => {21 test('when hook preAction then hook called before action', () => {2 unmodified lines24 program25 .hook('preAction', () => calls.push('before'))26 .action(() => calls.push('action'));27 program.parse([], { from: 'user' });26- expect(calls).toEqual(['before', 'action']);28+ assert.deepEqual(calls, ['before', 'action']);29 });30 31 test('when hook postAction then hook called after action', () => {32 const calls = [];1 unmodified line34 program35 .hook('postAction', () => calls.push('after'))36 .action(() => calls.push('action'));37 program.parse([], { from: 'user' });36- expect(calls).toEqual(['action', 'after']);38+ assert.deepEqual(calls, ['action', 'after']);39 });40 41 test('when hook preAction twice then hooks called FIFO', () => {42 const calls = [];2 unmodified lines45 .hook('preAction', () => calls.push('1'))46 .hook('preAction', () => calls.push('2'))47 .action(() => calls.push('action'));48 program.parse([], { from: 'user' });47- expect(calls).toEqual(['1', '2', 'action']);49+ assert.deepEqual(calls, ['1', '2', 'action']);50 });51 52 test('when hook postAction twice then hooks called LIFO', () => {53 const calls = [];2 unmodified lines56 .hook('postAction', () => calls.push('1'))57 .hook('postAction', () => calls.push('2'))58 .action(() => calls.push('action'));59 program.parse([], { from: 'user' });58- expect(calls).toEqual(['action', '2', '1']);60+ assert.deepEqual(calls, ['action', '2', '1']);61 });62 63 test('when hook preAction at program and sub then hooks called program then sub', () => {64 const calls = [];3 unmodified lines68 .command('sub')69 .hook('preAction', () => calls.push('sub'))70 .action(() => calls.push('action'));71 program.parse(['sub'], { from: 'user' });70- expect(calls).toEqual(['program', 'sub', 'action']);72+ assert.deepEqual(calls, ['program', 'sub', 'action']);73 });74 75 test('when hook postAction at program and sub then hooks called sub then program', () => {76 const calls = [];3 unmodified lines80 .command('sub')81 .hook('postAction', () => calls.push('sub'))82 .action(() => calls.push('action'));83 program.parse(['sub'], { from: 'user' });82- expect(calls).toEqual(['action', 'sub', 'program']);84+ assert.deepEqual(calls, ['action', 'sub', 'program']);85 });86 87 test('when hook everything then hooks called nested', () => {88 const calls = [];9 unmodified lines98 .hook('preAction', () => calls.push('sb'))99 .hook('postAction', () => calls.push('sa'))100 .action(() => calls.push('action'));101 program.parse(['sub'], { from: 'user' });100- expect(calls).toEqual(['pb1', 'pb2', 'sb', 'action', 'sa', 'pa2', 'pa1']);102+ assert.deepEqual(calls, ['pb1', 'pb2', 'sb', 'action', 'sa', 'pa2', 'pa1']);103 });104 });105 106 describe('action hooks context', () => {105- test('when hook on program then passed program/program', () => {106- const hook = jest.fn();107+ test('when hook on program then passed program/program', (t) => {108+ const hook = t.mock.fn();109 const program = new commander.Command();110 program.hook('preAction', hook).action(() => {});111 program.parse([], { from: 'user' });110- expect(hook).toHaveBeenCalledWith(program, program);112+ assert.equal(hook.mock.callCount(), 1);113+ const callArgs = hook.mock.calls[0].arguments;114+ assert.equal(callArgs[0], program);115+ assert.equal(callArgs[1], program);116 });117 113- test('when hook on program and call sub then passed program/sub', () => {114- const hook = jest.fn();118+ test('when hook on program and call sub then passed program/sub', (t) => {119+ const hook = t.mock.fn();120 const program = new commander.Command();121 program.hook('preAction', hook);122 const sub = program.command('sub').action(() => {});123 program.parse(['sub'], { from: 'user' });119- expect(hook).toHaveBeenCalledWith(program, sub);124+ assert.equal(hook.mock.callCount(), 1);125+ const callArgs = hook.mock.calls[0].arguments;126+ assert.equal(callArgs[0], program);127+ assert.equal(callArgs[1], sub);128 });129 122- test('when hook on sub and call sub then passed sub/sub', () => {123- const hook = jest.fn();130+ test('when hook on sub and call sub then passed sub/sub', (t) => {131+ const hook = t.mock.fn();132 const program = new commander.Command();133 const sub = program134 .command('sub')135 .hook('preAction', hook)136 .action(() => {});137 program.parse(['sub'], { from: 'user' });130- expect(hook).toHaveBeenCalledWith(sub, sub);138+ assert.equal(hook.mock.callCount(), 1);139+ const callArgs = hook.mock.calls[0].arguments;140+ assert.equal(callArgs[0], sub);141+ assert.equal(callArgs[1], sub);142 });143 144 test('when hook program on preAction then thisCommand has options set', () => {134- expect.assertions(1);145 const program = new commander.Command();146 program147 .option('--debug')148 .hook('preAction', (thisCommand) => {139- expect(thisCommand.opts().debug).toEqual(true);149+ assert.equal(thisCommand.opts().debug, true);150 })151 .action(() => {});152 program.parse(['--debug'], { from: 'user' });153 });154 155 test('when hook program on preAction and call sub then thisCommand has program options set', () => {146- expect.assertions(1);156 const program = new commander.Command();157 program.option('--debug').hook('preAction', (thisCommand) => {149- expect(thisCommand.opts().debug).toEqual(true);158+ assert.equal(thisCommand.opts().debug, true);159 });160 program.command('sub').action(() => {});161 program.parse(['sub', '--debug'], { from: 'user' });162 });163 164 test('when hook program on preAction and call sub then actionCommand has sub options set', () => {156- expect.assertions(1);165 const program = new commander.Command();166 program.hook('preAction', (thisCommand, actionCommand) => {159- expect(actionCommand.opts().debug).toEqual(true);167+ assert.equal(actionCommand.opts().debug, true);168 });169 program170 .command('sub')171 .option('--debug')1 unmodified line173 program.parse(['sub', '--debug'], { from: 'user' });174 });175 176 test('when hook program on preAction then actionCommand has args set', () => {169- expect.assertions(1);177 const program = new commander.Command();178 program179 .argument('[arg]')180 .hook('preAction', (thisCommand, actionCommand) => {174- expect(actionCommand.args).toEqual(['value']);181+ assert.deepEqual(actionCommand.args, ['value']);182 })183 .action(() => {});184 program.parse(['value'], { from: 'user' });185 });186 187 test('when hook program on preAction then actionCommand has args set with options removed', () => {181- expect.assertions(1);188 const program = new commander.Command();189 program190 .argument('[arg]')191 .option('--debug')192 .hook('preAction', (thisCommand, actionCommand) => {187- expect(actionCommand.args).toEqual(['value']);193+ assert.deepEqual(actionCommand.args, ['value']);194 })195 .action(() => {});196 program.parse(['value', '--debug'], { from: 'user' });197 });198 199 test('when hook program on preAction and call sub then thisCommand has program args set', () => {194- expect.assertions(1);200 const program = new commander.Command();201 program.argument('[arg]').hook('preAction', (thisCommand) => {197- expect(thisCommand.args).toEqual(['sub', 'value']);202+ assert.deepEqual(thisCommand.args, ['sub', 'value']);203 });204 program205 .command('sub')206 .argument('<arg>')1 unmodified line208 program.parse(['sub', 'value'], { from: 'user' });209 });210 211 test('when hook program on preAction and call sub then actionCommand has sub args set', () => {207- expect.assertions(1);212 const program = new commander.Command();213 program.hook('preAction', (thisCommand, actionCommand) => {210- expect(actionCommand.args).toEqual(['value']);214+ assert.deepEqual(actionCommand.args, ['value']);215 });216 program217 .command('sub')218 .argument('<arg>')12 unmodified lines231 calls.push('before');232 })233 .action(() => calls.push('action'));234 const result = program.parseAsync([], { from: 'user' });231- expect(calls).toEqual([]);235+ assert.deepEqual(calls, []);236 await result;233- expect(calls).toEqual(['before', 'action']);237+ assert.deepEqual(calls, ['before', 'action']);238 });239 240 test('when async postAction then async from postAction', async () => {241 const calls = [];4 unmodified lines246 calls.push('after');247 })248 .action(() => calls.push('action'));249 const result = program.parseAsync([], { from: 'user' });246- expect(calls).toEqual(['action']);250+ assert.deepEqual(calls, ['action']);251 await result;248- expect(calls).toEqual(['action', 'after']);252+ assert.deepEqual(calls, ['action', 'after']);253 });254 255 test('when async action then async from action', async () => {256 const calls = [];5 unmodified lines262 await 0;263 calls.push('action');264 });265 const result = program.parseAsync([], { from: 'user' });262- expect(calls).toEqual(['before']);266+ assert.deepEqual(calls, ['before']);267 await result;264- expect(calls).toEqual(['before', 'action', 'after']);268+ assert.deepEqual(calls, ['before', 'action', 'after']);269 });270 271 test('when async first preAction then async from first preAction', async () => {272 const calls = [];5 unmodified lines278 })279 .hook('preAction', () => calls.push('2'))280 .action(() => calls.push('action'));281 const result = program.parseAsync([], { from: 'user' });278- expect(calls).toEqual([]);282+ assert.deepEqual(calls, []);283 await result;280- expect(calls).toEqual(['1', '2', 'action']);284+ assert.deepEqual(calls, ['1', '2', 'action']);285 });286 287 test('when async second preAction then async from second preAction', async () => {288 const calls = [];5 unmodified lines294 calls.push('2');295 })296 .action(() => calls.push('action'));297 const result = program.parseAsync([], { from: 'user' });294- expect(calls).toEqual(['1']);298+ assert.deepEqual(calls, ['1']);299 await result;296- expect(calls).toEqual(['1', '2', 'action']);300+ assert.deepEqual(calls, ['1', '2', 'action']);301 });302 303 test('when async hook everything then hooks called nested', async () => {304 const calls = [];30 unmodified lines335 await 0;336 calls.push('action');337 });338 const result = program.parseAsync(['sub'], { from: 'user' });335- expect(calls).toEqual([]);339+ assert.deepEqual(calls, []);340 await result;337- expect(calls).toEqual(['pb1', 'pb2', 'sb', 'action', 'sa', 'pa2', 'pa1']);341+ assert.deepEqual(calls, ['pb1', 'pb2', 'sb', 'action', 'sa', 'pa2', 'pa1']);342 });343 344 test('preSubcommand hook should work', async () => {345 const calls = [];10 unmodified lines356 await 2;357 calls.push(2);358 });359 const result = program.parseAsync(['sub'], { from: 'user' });356- expect(calls).toEqual([]);360+ assert.deepEqual(calls, []);361 await result;358- expect(calls).toEqual([0, 1]);362+ assert.deepEqual(calls, [0, 1]);363 });364 test('preSubcommand hook should effective for direct subcommands', async () => {365 const calls = [];366 const program = new commander.Command();24 unmodified lines391 });392 const result = program.parseAsync(['first', 'second', 'third'], {393 from: 'user',394 });391- expect(calls).toEqual([]);395+ assert.deepEqual(calls, []);396 await result;393- expect(calls).toEqual(['preSubcommand', 'first', 'third']);397+ assert.deepEqual(calls, ['preSubcommand', 'first', 'third']);398 });399 });modified:tests/command.name.test.js+10 added-8 removed
1 const path = require('path');2 const commander = require('../');3+const { test } = require('node:test');4+const assert = require('node:assert/strict');5 6 test('when construct with name then name is set', () => {7 const program = new commander.Command('foo');6- expect(program.name()).toBe('foo');8+ assert.equal(program.name(), 'foo');9 });10 11 test('when set program name and parse then name is as assigned', () => {12 const program = new commander.Command();13 program.name('custom');14 program.parse(['node', 'test']);13- expect(program.name()).toBe('custom');15+ assert.equal(program.name(), 'custom');16 });17 18 test('when program name not set and parse with script argument then plain name is found from script name', () => {19 const program = new commander.Command();20 program.parse(['node', path.resolve(process.cwd(), 'script.js')], {21 from: 'node',22 });21- expect(program.name()).toBe('script');23+ assert.equal(program.name(), 'script');24 });25 26 test('when command name not set and no script argument in parse then name is program', () => {27 const program = new commander.Command();28 program.parse([], { from: 'user' });27- expect(program.name()).toBe('program');29+ assert.equal(program.name(), 'program');30 });31 32 test('when add command then command is named', () => {33 const program = new commander.Command();34 const subcommand = program.command('mycommand <file>');33- expect(subcommand.name()).toBe('mycommand');35+ assert.equal(subcommand.name(), 'mycommand');36 });37 38 test('when set program name then name appears in help', () => {39 const program = new commander.Command();40 program.name('custom-name');41 const helpInformation = program.helpInformation();40- expect(helpInformation).toMatch(/^Usage: custom-name/);42+ assert.match(helpInformation, /^Usage: custom-name/);43 });44 45 test('when pass path to nameFromFilename then name is plain name', () => {46 const program = new commander.Command();47 program.nameFromFilename(path.resolve(process.cwd(), 'foo.js'));46- expect(program.name()).toBe('foo');48+ assert.equal(program.name(), 'foo');49 });50 51 test('when pass __filename to nameFromFilename then name is plain name of this file', () => {52 const program = new commander.Command();53 program.nameFromFilename(__filename);52- expect(program.name()).toBe('command.name.test');54+ assert.equal(program.name(), 'command.name.test');55 });modified:tests/command.nested.test.js+5 added-3 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 3-test('when call nested subcommand then runs', () => {5+test('when call nested subcommand then runs', (t) => {6 const program = new commander.Command();5- const leafAction = jest.fn();7+ const leafAction = t.mock.fn();8 program.command('sub1').command('sub2').action(leafAction);9 program.parse('node test.js sub1 sub2'.split(' '));8- expect(leafAction).toHaveBeenCalled();10+ assert.equal(leafAction.mock.callCount(), 1);11 });modified:tests/command.onCommand.test.js+13 added-9 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // The action handler used to be implemented using command events and listeners.6 // Now, this is mostly just for backwards compatibility.7 8 describe(".command('*')", () => {7- test('when action handler for subcommand then emit command:subcommand', () => {8- const mockListener = jest.fn();9+ test('when action handler for subcommand then emit command:subcommand', (t) => {10+ const mockListener = t.mock.fn();11 const program = new commander.Command();12 program.command('sub').action(() => {});13 program.on('command:sub', mockListener);14 program.parse(['sub'], { from: 'user' });13- expect(mockListener).toHaveBeenCalled();15+ assert.equal(mockListener.mock.callCount(), 1);16 });17 16- test('when no action handler for subcommand then still emit command:subcommand', () => {17- const mockListener = jest.fn();18+ test('when no action handler for subcommand then still emit command:subcommand', (t) => {19+ const mockListener = t.mock.fn();20 const program = new commander.Command();21 program.command('sub');22 program.on('command:sub', mockListener);23 program.parse(['sub'], { from: 'user' });22- expect(mockListener).toHaveBeenCalled();24+ assert.equal(mockListener.mock.callCount(), 1);25 });26 25- test('when subcommand has argument then emit command:subcommand with argument', () => {26- const mockListener = jest.fn();27+ test('when subcommand has argument then emit command:subcommand with argument', (t) => {28+ const mockListener = t.mock.fn();29 const program = new commander.Command();30 program.command('sub <file>').action(() => {});31 program.on('command:sub', mockListener);32 program.parse(['sub', 'file'], { from: 'user' });31- expect(mockListener).toHaveBeenCalledWith(['file'], []);33+ assert.equal(mockListener.mock.callCount(), 1);34+ const callArgs = mockListener.mock.calls[0].arguments;35+ assert.deepEqual(callArgs, [['file'], []]);36 });37 });modified:tests/command.option-misuse.test.js+14 added-6 removed
1 const { Command, Option } = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // It is a reasonable and easy mistake to pass Option to .option(). Detect this6 // and offer advice.7 2 unmodified lines10 11 test('when pass Option to .option() then throw', () => {12 const program = new Command();13 12- expect(() => {13- program.option(new Option('-d, debug'));14- }).toThrow(expectedMessage);14+ assert.throws(15+ () => {16+ program.option(new Option('-d, debug'));17+ },18+ { message: expectedMessage },19+ );20 });21 22 test('when pass Option to .requiredOption() then throw', () => {23 const program = new Command();24 20- expect(() => {21- program.requiredOption(new Option('-d, debug'));22- }).toThrow(expectedMessage);25+ assert.throws(26+ () => {27+ program.requiredOption(new Option('-d, debug'));28+ },29+ { message: expectedMessage },30+ );31 });modified:tests/command.parse.test.js+89 added-83 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Testing some Electron conventions but not directly using Electron to avoid overheads.6 // https://github.com/electron/electron/issues/4690#issuecomment-2174352227 // https://www.electronjs.org/docs/api/process#processdefaultapp-readonly8 unmodified lines16 const hold = process.argv;17 process.argv = 'node script.js user'.split(' ');18 program.parse();19 process.argv = hold;18- expect(program.args).toEqual(['user']);20+ assert.deepEqual(program.args, ['user']);21 });22 23 test('when no args and electron properties and not default app then use process.argv and app/args', () => {24 const program = new commander.Command();3 unmodified lines28 process.argv = 'node user'.split(' ');29 program.parse();30 delete process.versions.electron;31 process.argv = holdArgv;30- expect(program.args).toEqual(['user']);32+ assert.deepEqual(program.args, ['user']);33 });34 35 test('when args then app/script/args', () => {36 const program = new commander.Command();37 program.argument('[args...]');38 program.parse('node script.js user'.split(' '));37- expect(program.args).toEqual(['user']);39+ assert.deepEqual(program.args, ['user']);40 });41 42 test('when args from "node" then app/script/args', () => {43 const program = new commander.Command();44 program.argument('[args...]');45 program.parse('node script.js user'.split(' '), { from: 'node' });44- expect(program.args).toEqual(['user']);46+ assert.deepEqual(program.args, ['user']);47 });48 49 test('when args from "electron" and not default app then app/args', () => {50 const program = new commander.Command();1 unmodified line52 const hold = process.defaultApp;53 process.defaultApp = undefined;54 program.parse('customApp user'.split(' '), { from: 'electron' });55 process.defaultApp = hold;54- expect(program.args).toEqual(['user']);56+ assert.deepEqual(program.args, ['user']);57 });58 59 test('when args from "electron" and default app then app/script/args', () => {60 const program = new commander.Command();1 unmodified line62 const hold = process.defaultApp;63 process.defaultApp = true;64 program.parse('electron script user'.split(' '), { from: 'electron' });65 process.defaultApp = hold;64- expect(program.args).toEqual(['user']);66+ assert.deepEqual(program.args, ['user']);67 });68 69 test('when args from "user" then args', () => {70 const program = new commander.Command();71 program.argument('[args...]');72 program.parse('user'.split(' '), { from: 'user' });71- expect(program.args).toEqual(['user']);73+ assert.deepEqual(program.args, ['user']);74 });75 76 test('when args from "silly" then throw', () => {77 const program = new commander.Command();78 program.argument('[args...]');77- expect(() => {79+ assert.throws(() => {80 program.parse(['node', 'script.js'], { from: 'silly' });79- }).toThrow();81+ });82 });83 82- test.each(['-e', '--eval', '-p', '--print'])(83- 'when node execArgv includes %s then app/args',84- (flag) => {85- const program = new commander.Command();86- program.argument('[args...]');87- const holdExecArgv = process.execArgv;88- const holdArgv = process.argv;89- process.argv = ['node', 'user-arg'];90- process.execArgv = [flag, 'console.log("hello, world")'];91- program.parse();92- process.argv = holdArgv;93- process.execArgv = holdExecArgv;94- expect(program.args).toEqual(['user-arg']);95- process.execArgv = holdExecArgv;96- },97- );84+ describe('when node execArgv includes node flags', () => {85+ ['-e', '--eval', '-p', '--print'].forEach((flag) => {86+ test(`when node execArgv includes ${flag} then app/args`, () => {87+ const program = new commander.Command();88+ program.argument('[args...]');89+ const holdExecArgv = process.execArgv;90+ const holdArgv = process.argv;91+ process.argv = ['node', 'user-arg'];92+ process.execArgv = [flag, 'console.log("hello, world")'];93+ program.parse();94+ process.argv = holdArgv;95+ process.execArgv = holdExecArgv;96+ assert.deepEqual(program.args, ['user-arg']);97+ process.execArgv = holdExecArgv;98+ });99+ });100+ });101 });102 103 describe('return type', () => {104 test('when call .parse then returns program', () => {1 unmodified line106 program.argument('[args...]');107 program.action(() => {});108 109 const result = program.parse(['node', 'test']);107- expect(result).toBe(program);110+ assert.equal(result, program);111 });112 113 test('when await .parseAsync then returns program', async () => {114 const program = new commander.Command();115 program.argument('[args...]');116 program.action(() => {});117 118 const result = await program.parseAsync(['node', 'test']);116- expect(result).toBe(program);119+ assert.equal(result, program);120 });121 });122 123 // Easy mistake to make when writing unit tests124 test('when parse strings instead of array then throw', () => {125 const program = new commander.Command();126 program.argument('[args...]');124- expect(() => {127+ assert.throws(() => {128 program.parse('node', 'test');126- }).toThrow();129+ });130 });131 132 describe('parse parameter is treated as readonly, per TypeScript declaration', () => {133 test('when parse called then parameter does not change', () => {2 unmodified lines136 program.option('--debug');137 const original = ['node', '--debug', 'arg'];138 const param = original.slice();139 program.parse(param);137- expect(param).toEqual(original);140+ assert.deepEqual(param, original);141 });142 143 test('when parse called and parsed args later changed then parameter does not change', () => {144 const program = new commander.Command();3 unmodified lines148 const param = original.slice();149 program.parse(param);150 program.args.length = 0;151 program.rawArgs.length = 0;149- expect(param).toEqual(original);152+ assert.deepEqual(param, original);153 });154 155 test('when parse called and param later changed then parsed args do not change', () => {156 const program = new commander.Command();3 unmodified lines160 program.parse(param);161 const oldArgs = program.args.slice();162 const oldRawArgs = program.rawArgs.slice();163 param.length = 0;161- expect(program.args).toEqual(oldArgs);162- expect(program.rawArgs).toEqual(oldRawArgs);164+ assert.deepEqual(program.args, oldArgs);165+ assert.deepEqual(program.rawArgs, oldRawArgs);166 });167 });168 169 describe('parseAsync parameter is treated as readonly, per TypeScript declaration', () => {3 unmodified lines173 program.option('--debug');174 const original = ['node', '--debug', 'arg'];175 const param = original.slice();176 await program.parseAsync(param);174- expect(param).toEqual(original);177+ assert.deepEqual(param, original);178 });179 180 test('when parseAsync called and parsed args later changed then parameter does not change', async () => {181 const program = new commander.Command();3 unmodified lines185 const param = original.slice();186 await program.parseAsync(param);187 program.args.length = 0;188 program.rawArgs.length = 0;186- expect(param).toEqual(original);189+ assert.deepEqual(param, original);190 });191 192 test('when parseAsync called and param later changed then parsed args do not change', async () => {193 const program = new commander.Command();3 unmodified lines197 await program.parseAsync(param);198 const oldArgs = program.args.slice();199 const oldRawArgs = program.rawArgs.slice();200 param.length = 0;198- expect(program.args).toEqual(oldArgs);199- expect(program.rawArgs).toEqual(oldRawArgs);201+ assert.deepEqual(program.args, oldArgs);202+ assert.deepEqual(program.rawArgs, oldRawArgs);203 });204 });205 206 describe('.parse() called multiple times', () => {207 test('when use boolean options then option values reset', () => {208 const program = new commander.Command().option('--black').option('--white');209 210 program.parse(['--black'], { from: 'user' });208- expect(program.opts()).toEqual({ black: true });211+ assert.deepEqual(program.opts(), { black: true });212 213 program.parse(['--white'], { from: 'user' });211- expect(program.opts()).toEqual({ white: true });214+ assert.deepEqual(program.opts(), { white: true });215 });216 217 test('when use options with option-argument then option values and sources reset', () => {218 const program = new commander.Command()219 .option('-f, --foo <value>')220 .option('-b, --bar <value>');221 222 program.parse(['--foo', 'FOO'], { from: 'user' });220- expect(program.opts()).toEqual({ foo: 'FOO' });221- expect(program.getOptionValueSource('foo')).toEqual('cli');222- expect(program.getOptionValueSource('bar')).toBeUndefined();223+ assert.deepEqual(program.opts(), { foo: 'FOO' });224+ assert.equal(program.getOptionValueSource('foo'), 'cli');225+ assert.equal(program.getOptionValueSource('bar'), undefined);226 227 program.parse(['--bar', 'BAR'], { from: 'user' });225- expect(program.opts()).toEqual({ bar: 'BAR' });226- expect(program.getOptionValueSource('foo')).toBeUndefined();227- expect(program.getOptionValueSource('bar')).toEqual('cli');228+ assert.deepEqual(program.opts(), { bar: 'BAR' });229+ assert.equal(program.getOptionValueSource('foo'), undefined);230+ assert.equal(program.getOptionValueSource('bar'), 'cli');231 });232 233 test('when use options with option-argument and default then option values and sources reset', () => {234 const program = new commander.Command()235 .option('-f, --foo <value>', 'description', 'default-FOO')236 .option('-b, --bar <value>', 'description', 'default-BAR');237 238 program.parse(['--foo', 'FOO'], { from: 'user' });236- expect(program.opts()).toEqual({ foo: 'FOO', bar: 'default-BAR' });237- expect(program.getOptionValueSource('foo')).toEqual('cli');238- expect(program.getOptionValueSource('bar')).toEqual('default');239+ assert.deepEqual(program.opts(), { foo: 'FOO', bar: 'default-BAR' });240+ assert.equal(program.getOptionValueSource('foo'), 'cli');241+ assert.equal(program.getOptionValueSource('bar'), 'default');242 243 program.parse(['--bar', 'BAR'], { from: 'user' });241- expect(program.opts()).toEqual({ foo: 'default-FOO', bar: 'BAR' });242- expect(program.getOptionValueSource('foo')).toEqual('default');243- expect(program.getOptionValueSource('bar')).toEqual('cli');244+ assert.deepEqual(program.opts(), { foo: 'default-FOO', bar: 'BAR' });245+ assert.equal(program.getOptionValueSource('foo'), 'default');246+ assert.equal(program.getOptionValueSource('bar'), 'cli');247 });248 249 test('when use negated options then option values reset', () => {250 const program = new commander.Command()251 .option('--no-foo')252 .option('--no-bar');253 254 program.parse(['--no-foo'], { from: 'user' });252- expect(program.opts()).toEqual({ foo: false, bar: true });255+ assert.deepEqual(program.opts(), { foo: false, bar: true });256 257 program.parse(['--no-bar'], { from: 'user' });255- expect(program.opts()).toEqual({ foo: true, bar: false });258+ assert.deepEqual(program.opts(), { foo: true, bar: false });259 });260 261 test('when use variadic option then option values reset', () => {262 const program = new commander.Command().option('--var <items...>');263 264 program.parse(['--var', 'a', 'b'], { from: 'user' });262- expect(program.opts()).toEqual({ var: ['a', 'b'] });265+ assert.deepEqual(program.opts(), { var: ['a', 'b'] });266 267 program.parse(['--var', 'c'], { from: 'user' });265- expect(program.opts()).toEqual({ var: ['c'] });268+ assert.deepEqual(program.opts(), { var: ['c'] });269 });270 271 test('when use collect example then option value resets', () => {272 function collect(value, previous) {2 unmodified lines275 const program = new commander.Command();276 program.option('-c, --collect <value>', 'repeatable value', collect, []);277 278 program.parse(['-c', 'a', '-c', 'b'], { from: 'user' });276- expect(program.opts()).toEqual({ collect: ['a', 'b'] });279+ assert.deepEqual(program.opts(), { collect: ['a', 'b'] });280 281 program.parse(['-c', 'c'], { from: 'user' });279- expect(program.opts()).toEqual({ collect: ['c'] });282+ assert.deepEqual(program.opts(), { collect: ['c'] });283 });284 285 test('when use increaseVerbosity example then option value resets', () => {286 function increaseVerbosity(dummyValue, previous) {7 unmodified lines294 0,295 );296 297 program.parse(['-vvv'], { from: 'user' });295- expect(program.opts()).toEqual({ verbose: 3 });298+ assert.deepEqual(program.opts(), { verbose: 3 });299 program.parse(['-vv'], { from: 'user' });300 298- expect(program.opts()).toEqual({ verbose: 2 });301+ assert.deepEqual(program.opts(), { verbose: 2 });302 program.parse([], { from: 'user' });300- expect(program.opts()).toEqual({ verbose: 0 });303+ assert.deepEqual(program.opts(), { verbose: 0 });304 });305 306 test('when use parse and parseAsync then option values reset', async () => {307 const program = new commander.Command().option('--black').option('--white');308 309 program.parse(['--black'], { from: 'user' });307- expect(program.opts()).toEqual({ black: true });310+ assert.deepEqual(program.opts(), { black: true });311 await program.parseAsync(['--white'], { from: 'user' });309- expect(program.opts()).toEqual({ white: true });312+ assert.deepEqual(program.opts(), { white: true });313 });314 315 test('when call subcommand then option values reset (program and subcommand)', () => {316 const program = new commander.Command().option('--black').option('--white');317 const subcommand = program.command('sub').option('--red').option('--green');318 319 program.parse(['--black', 'sub', '--red'], { from: 'user' });317- expect(subcommand.optsWithGlobals()).toEqual({ black: true, red: true });320+ assert.deepEqual(subcommand.optsWithGlobals(), { black: true, red: true });321 322 program.parse(['--white', 'sub', '--green'], { from: 'user' });320- expect(subcommand.optsWithGlobals()).toEqual({ white: true, green: true });323+ assert.deepEqual(subcommand.optsWithGlobals(), {324+ white: true,325+ green: true,326+ });327 });328 329 test('when call different subcommand then no reset because lazy', () => {330 // This is not a required behaviour, but is the intended behaviour.1 unmodified line332 const sub1 = program.command('sub1').option('--red');333 const sub2 = program.command('sub2').option('--green');334 335 program.parse(['sub1', '--red'], { from: 'user' });330- expect(sub1.opts()).toEqual({ red: true });331- expect(sub2.opts()).toEqual({});336+ assert.deepEqual(sub1.opts(), { red: true });337+ assert.deepEqual(sub2.opts(), {});338 339 program.parse(['sub2', '--green'], { from: 'user' });334- expect(sub1.opts()).toEqual({ red: true });335- expect(sub2.opts()).toEqual({ green: true });340+ assert.deepEqual(sub1.opts(), { red: true });341+ assert.deepEqual(sub2.opts(), { green: true });342 });343 344 test('when parse with different implied program name then name changes', () => {345 const program = new commander.Command();346 347 program.parse(['node', 'script1.js']);342- expect(program.name()).toEqual('script1');348+ assert.equal(program.name(), 'script1');349 350 program.parse(['electron', 'script2.js']);345- expect(program.name()).toEqual('script2');351+ assert.equal(program.name(), 'script2');352 });353 354 test('when parse with different arguments then args change', () => {355 // weak test, would work without store/reset!1 unmodified line357 .argument('<first>')358 .argument('[second]');359 360 program.parse(['one', 'two'], { from: 'user' });355- expect(program.args).toEqual(['one', 'two']);361+ assert.deepEqual(program.args, ['one', 'two']);362 363 program.parse(['alpha'], { from: 'user' });358- expect(program.args).toEqual(['alpha']);364+ assert.deepEqual(program.args, ['alpha']);365 });366 367 test('when parse with different arguments then rawArgs change', () => {368 // weak test, would work without store/reset!2 unmodified lines371 .option('--white')372 .option('--black');373 374 program.parse(['--white', 'one'], { from: 'user' });369- expect(program.rawArgs).toEqual(['--white', 'one']);375+ assert.deepEqual(program.rawArgs, ['--white', 'one']);376 377 program.parse(['--black', 'two'], { from: 'user' });372- expect(program.rawArgs).toEqual(['--black', 'two']);378+ assert.deepEqual(program.rawArgs, ['--black', 'two']);379 });380 381 test('when parse with different arguments then processedArgs change', () => {382 // weak test, would work without store/reset!3 unmodified lines386 parseFloat,387 );388 389 program.parse([123], { from: 'user' });384- expect(program.processedArgs).toEqual([123]);390+ assert.deepEqual(program.processedArgs, [123]);391 392 program.parse([456], { from: 'user' });387- expect(program.processedArgs).toEqual([456]);393+ assert.deepEqual(program.processedArgs, [456]);394 });395 396 test('when parse subcommand then reset state before preSubcommand hook called', () => {397 let hookCalled = false;398 const program = new commander.Command().hook(399 'preSubcommand',400 (thisCommand, subcommand) => {401 hookCalled = true;396- expect(subcommand.opts()).toEqual({});402+ assert.deepEqual(subcommand.opts(), {});403 },404 );405 const subcommand = program.command('sub').option('--red').option('--green');406 407 hookCalled = false;408 program.parse(['sub', '--red'], { from: 'user' });403- expect(hookCalled).toBe(true);404- expect(subcommand.opts()).toEqual({ red: true });409+ assert.equal(hookCalled, true);410+ assert.deepEqual(subcommand.opts(), { red: true });411 412 hookCalled = false;413 program.parse(['sub', '--green'], { from: 'user' });408- expect(hookCalled).toBe(true);409- expect(subcommand.opts()).toEqual({ green: true });414+ assert.equal(hookCalled, true);415+ assert.deepEqual(subcommand.opts(), { green: true });416 });417 418 test('when using storeOptionsAsProperties then throw on second parse', () => {419 const program = new commander.Command().storeOptionsAsProperties();420 program.parse();415- expect(() => {421+ assert.throws(() => {422 program.parse();417- }).toThrow();423+ });424 });425 });modified:tests/command.parseOptions.test.js+46 added-41 removed
1 const childProcess = require('child_process');2 const commander = require('../');3 const path = require('path');4 const util = require('util');5+const { test, describe } = require('node:test');6+const assert = require('node:assert/strict');7 8 const execFileAsync = util.promisify(childProcess.execFile);9 10 // Combination of parse and parseOptions tests which are more about details14 unmodified lines25 // https://github.com/tj/commander.js/issues/103226 test('when specify subcommand and argument then program.args not empty', () => {27 const program = createProgram1032();28 program.parse(['node', 'test.js', 'doit', 'myid']);27- expect(program.args.length).toBeGreaterThan(0);29+ assert(program.args.length > 0);30 });31 32 // https://github.com/tj/commander.js/issues/103233 test('when specify subcommand and option and argument then program.args not empty', () => {34 const program = createProgram1032();35 program.parse(['node', 'test.js', 'doit', '--better', 'myid']);34- expect(program.args.length).toBeGreaterThan(0);36+ assert(program.args.length > 0);37 });38 39 // https://github.com/tj/commander.js/issues/50840 test('when arguments to executable include option flags then argument order preserved', async () => {8 unmodified lines49 '4',50 '5',51 '6',52 ]);51- expect(stdout).toBe("[ '1', '2', '--dry-run', '3', '4', '5', '6' ]\n");53+ assert.equal(stdout, "[ '1', '2', '--dry-run', '3', '4', '5', '6' ]\n");54 });55 });56 57 describe('parseOptions', () => {12 unmodified lines70 71 test('when empty args then empty results', () => {72 const program = createProgram();73 const result = program.parseOptions([]);72- expect(result).toEqual({ operands: [], unknown: [] });74+ assert.deepEqual(result, { operands: [], unknown: [] });75 });76 77 test('when only operands then results has all operands', () => {78 const program = createProgram();79 const result = program.parseOptions('one two three'.split(' '));78- expect(result).toEqual({ operands: ['one', 'two', 'three'], unknown: [] });80+ assert.deepEqual(result, {81+ operands: ['one', 'two', 'three'],82+ unknown: [],83+ });84 });85 86 test('when subcommand and operand then results has subcommand and operand', () => {87 const program = createProgram();88 const result = program.parseOptions('sub one'.split(' '));84- expect(result).toEqual({ operands: ['sub', 'one'], unknown: [] });89+ assert.deepEqual(result, { operands: ['sub', 'one'], unknown: [] });90 });91 92 test('when program has flag then option removed', () => {93 const program = createProgram();94 const result = program.parseOptions('--global-flag'.split(' '));90- expect(result).toEqual({ operands: [], unknown: [] });95+ assert.deepEqual(result, { operands: [], unknown: [] });96 });97 98 test('when program has option with value then option removed', () => {99 const program = createProgram();100 const result = program.parseOptions('--global-value foo'.split(' '));96- expect(result).toEqual({ operands: [], unknown: [] });101+ assert.deepEqual(result, { operands: [], unknown: [] });102 });103 104 test('when program has flag before operand then option removed', () => {105 const program = createProgram();106 const result = program.parseOptions('--global-flag arg'.split(' '));102- expect(result).toEqual({ operands: ['arg'], unknown: [] });107+ assert.deepEqual(result, { operands: ['arg'], unknown: [] });108 });109 110 test('when program has flag after operand then option removed', () => {111 const program = createProgram();112 const result = program.parseOptions('arg --global-flag'.split(' '));108- expect(result).toEqual({ operands: ['arg'], unknown: [] });113+ assert.deepEqual(result, { operands: ['arg'], unknown: [] });114 });115 116 test('when program has flag after subcommand then option removed', () => {117 const program = createProgram();118 const result = program.parseOptions('sub --global-flag'.split(' '));114- expect(result).toEqual({ operands: ['sub'], unknown: [] });119+ assert.deepEqual(result, { operands: ['sub'], unknown: [] });120 });121 122 test('when program has unknown option then option returned in unknown', () => {123 const program = createProgram();124 const result = program.parseOptions('--unknown'.split(' '));120- expect(result).toEqual({ operands: [], unknown: ['--unknown'] });125+ assert.deepEqual(result, { operands: [], unknown: ['--unknown'] });126 });127 128 test('when program has unknown option before operands then all unknown in same order', () => {129 const program = createProgram();130 const result = program.parseOptions('--unknown arg'.split(' '));126- expect(result).toEqual({ operands: [], unknown: ['--unknown', 'arg'] });131+ assert.deepEqual(result, { operands: [], unknown: ['--unknown', 'arg'] });132 });133 134 test('when program has unknown option after operand then option returned in unknown', () => {135 const program = createProgram();136 const result = program.parseOptions('arg --unknown'.split(' '));132- expect(result).toEqual({ operands: ['arg'], unknown: ['--unknown'] });137+ assert.deepEqual(result, { operands: ['arg'], unknown: ['--unknown'] });138 });139 140 test('when program has flag after unknown option then flag removed', () => {141 const program = createProgram();142 const result = program.parseOptions('--unknown --global-flag'.split(' '));138- expect(result).toEqual({ operands: [], unknown: ['--unknown'] });143+ assert.deepEqual(result, { operands: [], unknown: ['--unknown'] });144 });145 146 test('when subcommand has flag then flag returned as unknown', () => {147 const program = createProgram();148 const result = program.parseOptions('sub --sub-flag'.split(' '));144- expect(result).toEqual({ operands: ['sub'], unknown: ['--sub-flag'] });149+ assert.deepEqual(result, { operands: ['sub'], unknown: ['--sub-flag'] });150 });151 152 test('when program has literal before known flag then option returned as operand', () => {153 const program = createProgram();154 const result = program.parseOptions('-- --global-flag'.split(' '));150- expect(result).toEqual({ operands: ['--global-flag'], unknown: [] });155+ assert.deepEqual(result, { operands: ['--global-flag'], unknown: [] });156 });157 158 test('when program has literal before unknown option then option returned as operand', () => {159 const program = createProgram();160 const result = program.parseOptions('-- --unknown uuu'.split(' '));156- expect(result).toEqual({ operands: ['--unknown', 'uuu'], unknown: [] });161+ assert.deepEqual(result, { operands: ['--unknown', 'uuu'], unknown: [] });162 });163 164 test('when program has literal after unknown option then literal preserved too', () => {165 const program = createProgram();166 const result = program.parseOptions('--unknown1 -- --unknown2'.split(' '));162- expect(result).toEqual({167+ assert.deepEqual(result, {168 operands: [],169 unknown: ['--unknown1', '--', '--unknown2'],170 });171 });4 unmodified lines176 test('when program has known flag and operand then option removed and operand returned', () => {177 const program = new commander.Command();178 program.option('--global-flag').argument('[arg...]');179 program.parse('node test.js --global-flag arg'.split(' '));175- expect(program.args).toEqual(['arg']);180+ assert.deepEqual(program.args, ['arg']);181 });182 183 test('when program has mixed arguments then known options removed and rest returned in same order', () => {184 const program = new commander.Command();6 unmodified lines191 'node test.js aaa --global-flag bbb --unknown ccc --global-value value'.split(192 ' ',193 ),194 );190- expect(program.args).toEqual(['aaa', 'bbb', '--unknown', 'ccc']);195+ assert.deepEqual(program.args, ['aaa', 'bbb', '--unknown', 'ccc']);196 });197 198 test('when subcommand has mixed arguments then program flags removed and rest returned in same order', () => {199 const program = new commander.Command();6 unmodified lines206 'node test.js --global-flag sub --sub-flag arg --global-value value'.split(207 ' ',208 ),209 );205- expect(program.args).toEqual(['sub', '--sub-flag', 'arg']);210+ assert.deepEqual(program.args, ['sub', '--sub-flag', 'arg']);211 });212 });213 214 // Utility Conventions: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_0143 unmodified lines258 259 test('when program has combo known boolean short flags then arg removed', () => {260 const program = createProgram();261 const result = program.parseOptions(['-ab']);257- expect(result).toEqual({ operands: [], unknown: [] });258- expect(program.opts()).toEqual({ aaa: true, bbb: true });262+ assert.deepEqual(result, { operands: [], unknown: [] });263+ assert.deepEqual(program.opts(), { aaa: true, bbb: true });264 });265 266 test('when program has combo unknown short flags then arg preserved', () => {267 const program = createProgram();268 const result = program.parseOptions(['-pq']);264- expect(result).toEqual({ operands: [], unknown: ['-pq'] });265- expect(program.opts()).toEqual({});269+ assert.deepEqual(result, { operands: [], unknown: ['-pq'] });270+ assert.deepEqual(program.opts(), {});271 });272 273 test('when program has combo known short option and required value then arg removed', () => {274 const program = createProgram();275 const result = program.parseOptions(['-cvalue']);271- expect(result).toEqual({ operands: [], unknown: [] });272- expect(program.opts()).toEqual({ ccc: 'value' });276+ assert.deepEqual(result, { operands: [], unknown: [] });277+ assert.deepEqual(program.opts(), { ccc: 'value' });278 });279 280 test('when program has combo known short option and optional value then arg removed', () => {281 const program = createProgram();282 const result = program.parseOptions(['-dvalue']);278- expect(result).toEqual({ operands: [], unknown: [] });279- expect(program.opts()).toEqual({ ddd: 'value' });283+ assert.deepEqual(result, { operands: [], unknown: [] });284+ assert.deepEqual(program.opts(), { ddd: 'value' });285 });286 287 test('when program has known combo short boolean flags and required value then arg removed', () => {288 const program = createProgram();289 const result = program.parseOptions(['-abcvalue']);285- expect(result).toEqual({ operands: [], unknown: [] });286- expect(program.opts()).toEqual({ aaa: true, bbb: true, ccc: 'value' });290+ assert.deepEqual(result, { operands: [], unknown: [] });291+ assert.deepEqual(program.opts(), { aaa: true, bbb: true, ccc: 'value' });292 });293 294 test('when program has known combo short boolean flags and optional value then arg removed', () => {295 const program = createProgram();296 const result = program.parseOptions(['-abdvalue']);292- expect(result).toEqual({ operands: [], unknown: [] });293- expect(program.opts()).toEqual({ aaa: true, bbb: true, ddd: 'value' });297+ assert.deepEqual(result, { operands: [], unknown: [] });298+ assert.deepEqual(program.opts(), { aaa: true, bbb: true, ddd: 'value' });299 });300 301 test('when program has known long flag=value then arg removed', () => {302 const program = createProgram();303 const result = program.parseOptions(['--ccc=value']);299- expect(result).toEqual({ operands: [], unknown: [] });300- expect(program.opts()).toEqual({ ccc: 'value' });304+ assert.deepEqual(result, { operands: [], unknown: [] });305+ assert.deepEqual(program.opts(), { ccc: 'value' });306 });307 308 test('when program has unknown long flag=value then arg preserved', () => {309 const program = createProgram();310 const result = program.parseOptions(['--rrr=value']);306- expect(result).toEqual({ operands: [], unknown: ['--rrr=value'] });307- expect(program.opts()).toEqual({});311+ assert.deepEqual(result, { operands: [], unknown: ['--rrr=value'] });312+ assert.deepEqual(program.opts(), {});313 });314 315 test('when program has combo optional and combineFlagAndOptionalValue() then treat as value', () => {316 const program = createProgram();317 program.combineFlagAndOptionalValue();318 program.parseOptions(['-db']);314- expect(program.opts()).toEqual({ ddd: 'b' });319+ assert.deepEqual(program.opts(), { ddd: 'b' });320 });321 322 test('when program has combo optional and combineFlagAndOptionalValue(true) then treat as value', () => {323 const program = createProgram();324 program.combineFlagAndOptionalValue(true);325 program.parseOptions(['-db']);321- expect(program.opts()).toEqual({ ddd: 'b' });326+ assert.deepEqual(program.opts(), { ddd: 'b' });327 });328 329 test('when program has combo optional and combineFlagAndOptionalValue(false) then treat as boolean', () => {330 const program = createProgram();331 program.combineFlagAndOptionalValue(false);332 program.parseOptions(['-db']);328- expect(program.opts()).toEqual({ ddd: true, bbb: true });333+ assert.deepEqual(program.opts(), { ddd: true, bbb: true });334 });335 });modified:tests/command.positionalOptions.test.js+129 added-119 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // The changes to parsing for positional options are subtle, and took extra care to work with6 // implicit help and default commands. Lots of tests.7 7 unmodified lines15 16 test('when option before command-argument then option parsed', () => {17 const program = makeProgram();18 program.parse(['--debug', 'arg'], { from: 'user' });17- expect(program.args).toEqual(['arg']);18- expect(program.opts().debug).toBe(true);19+ assert.deepEqual(program.args, ['arg']);20+ assert.equal(program.opts().debug, true);21 });22 23 test('when known option after command-argument then option passed through', () => {24 const program = makeProgram();25 program.parse(['arg', '--debug'], { from: 'user' });24- expect(program.args).toEqual(['arg', '--debug']);25- expect(program.opts().debug).toBeUndefined();26+ assert.deepEqual(program.args, ['arg', '--debug']);27+ assert.equal(program.opts().debug, undefined);28 });29 30 test('when unknown option after command-argument then option passed through', () => {31 const program = makeProgram();32 program.parse(['arg', '--pass'], { from: 'user' });31- expect(program.args).toEqual(['arg', '--pass']);33+ assert.deepEqual(program.args, ['arg', '--pass']);34 });35 34- test('when action handler and unknown option after command-argument then option passed through', () => {36+ test('when action handler and unknown option after command-argument then option passed through', (t) => {37 const program = makeProgram();36- const mockAction = jest.fn();38+ const mockAction = t.mock.fn();39 program.action(mockAction);40 program.parse(['arg', '--pass'], { from: 'user' });39- expect(mockAction).toHaveBeenCalledWith(40- ['arg', '--pass'],41- program.opts(),42- program,43- );41+ assert.equal(mockAction.mock.callCount(), 1);42+ const callArgs = mockAction.mock.calls[0].arguments;43+ assert.deepEqual(callArgs[0], ['arg', '--pass']);44 });45 46- test('when help option (without command-argument) then help called', () => {46+ test('when help option (without command-argument) then help called', (t) => {47 const program = makeProgram();48- const mockHelp = jest.fn(() => '');48+ const mockHelp = t.mock.fn(() => '');49 50 program.exitOverride().configureHelp({ formatHelp: mockHelp });51 try {52 program.parse(['--help'], { from: 'user' });53 } catch (err) {54 /* empty */55 }56- expect(mockHelp).toHaveBeenCalled();56+ assert.equal(mockHelp.mock.callCount(), 1);57 });58 59 test('when help option after command-argument then option passed through', () => {60 const program = makeProgram();61 program.parse(['arg', '--help'], { from: 'user' });62- expect(program.args).toEqual(['arg', '--help']);62+ assert.deepEqual(program.args, ['arg', '--help']);63 });64 65 test('when version option after command-argument then option passed through', () => {66 const program = makeProgram();67 program.version('1.2.3');68 program.parse(['arg', '--version'], { from: 'user' });69- expect(program.args).toEqual(['arg', '--version']);69+ assert.deepEqual(program.args, ['arg', '--version']);70 });71 });72 73 // -----------------------------------------------------------15 unmodified lines89 90 test('when global option before subcommand then global option parsed', () => {91 const { program } = makeProgram();92 program.parse(['--shared', 'program', 'sub'], { from: 'user' });93- expect(program.opts().shared).toEqual('program');93+ assert.equal(program.opts().shared, 'program');94 });95 96 test('when shared option after subcommand then parsed by subcommand', () => {97 const { program, sub } = makeProgram();98 program.parse(['sub', '--shared', 'local'], { from: 'user' });99- expect(sub.opts().shared).toEqual('local');100- expect(program.opts().shared).toBeUndefined();99+ assert.equal(sub.opts().shared, 'local');100+ assert.equal(program.opts().shared, undefined);101 });102 103 test('when shared option after subcommand argument then parsed by subcommand', () => {104 const { program, sub } = makeProgram();105 program.parse(['sub', 'arg', '--shared', 'local'], { from: 'user' });106- expect(sub.opts().shared).toEqual('local');107- expect(sub.args).toEqual(['arg']);108- expect(program.opts().shared).toBeUndefined();106+ assert.equal(sub.opts().shared, 'local');107+ assert.deepEqual(sub.args, ['arg']);108+ assert.equal(program.opts().shared, undefined);109 });110 111 test('when shared option before and after subcommand then both parsed', () => {112 const { program, sub } = makeProgram();113 program.parse(['--shared', 'program', 'sub', '--shared', 'local'], {114 from: 'user',115 });116- expect(program.opts().shared).toEqual('program');117- expect(sub.opts().shared).toEqual('local');116+ assert.equal(program.opts().shared, 'program');117+ assert.equal(sub.opts().shared, 'local');118 });119 120- test.each([121- [[], 1, 0],122- [['sub'], 0, 0],123- [['--help'], 1, 0],124- [['sub', '--help'], 0, 1],125- [['sub', 'foo', '--help'], 0, 1],126- [['help'], 1, 0],127- [['help', 'sub'], 0, 1],128- ])(129- 'help: when user args %p then program/sub help called %p/%p',130- (userArgs, expectProgramHelpCount, expectSubHelpCount) => {131- const { program, sub } = makeProgram();132- const mockProgramHelp = jest.fn();133- program.exitOverride().configureHelp({ formatHelp: mockProgramHelp });134- const mockSubHelp = jest.fn();135- sub.exitOverride().configureHelp({ formatHelp: mockSubHelp });120+ describe('help', () => {121+ const cases = [122+ { args: [], programHelp: 1, subHelp: 0 },123+ { args: ['sub'], programHelp: 0, subHelp: 0 },124+ { args: ['--help'], programHelp: 1, subHelp: 0 },125+ { args: ['sub', '--help'], programHelp: 0, subHelp: 1 },126+ { args: ['sub', 'foo', '--help'], programHelp: 0, subHelp: 1 },127+ { args: ['help'], programHelp: 1, subHelp: 0 },128+ { args: ['help', 'sub'], programHelp: 0, subHelp: 1 },129+ ];130 131+ for (const { args, programHelp, subHelp } of cases) {132+ test(`when user args ${JSON.stringify(args)} then program/sub help called ${programHelp}/${subHelp}`, (t) => {133+ const { program, sub } = makeProgram();134+ const mockProgramHelp = t.mock.fn();135+ program.exitOverride().configureHelp({ formatHelp: mockProgramHelp });136+ const mockSubHelp = t.mock.fn();137+ sub.exitOverride().configureHelp({ formatHelp: mockSubHelp });138+137- try {138- program.parse(userArgs, { from: 'user' });139- } catch (err) {140- /* empty */141- }142- expect(mockProgramHelp).toHaveBeenCalledTimes(expectProgramHelpCount);143- expect(mockSubHelp).toHaveBeenCalledTimes(expectSubHelpCount);144- },145- );139+ try {140+ program.parse(args, { from: 'user' });141+ } catch (err) {142+ /* empty */143+ }144+ assert.equal(mockProgramHelp.mock.callCount(), programHelp);145+ assert.equal(mockSubHelp.mock.callCount(), subHelp);146+ });147+ }148+ });149 });150 151 // ---------------------------------------------------------------152 17 unmodified lines170 171 test('when program option before sub option then program option read by program', () => {172 const { program } = makeProgram();173 program.parse(['--global', '--default'], { from: 'user' });171- expect(program.opts().global).toBe(true);174+ assert.equal(program.opts().global, true);175 });176 177 test('when program option before sub option then sub option read by sub', () => {178 const { program, sub } = makeProgram();179 program.parse(['--global', '--default'], { from: 'user' });177- expect(sub.opts().default).toBe(true);180+ assert.equal(sub.opts().default, true);181 });182 183 test('when shared option before sub argument then option read by program', () => {184 const { program } = makeProgram();185 program.parse(['--shared', 'foo'], { from: 'user' });183- expect(program.opts().shared).toBe(true);186+ assert.equal(program.opts().shared, true);187 });188 189 test('when shared option after sub argument then option read by sub', () => {190 const { program, sub } = makeProgram();191 program.parse(['foo', '--shared'], { from: 'user' });189- expect(sub.opts().shared).toBe(true);192+ assert.equal(sub.opts().shared, true);193 });194 192- test.each([193- [[], 0, 0],194- [['--help'], 1, 0],195- [['help'], 1, 0],196- ])(197- 'help: when user args %p then program/sub help called %p/%p',198- (userArgs, expectProgramHelpCount, expectSubHelpCount) => {199- const { program, sub } = makeProgram();200- const mockProgramHelp = jest.fn();201- program.exitOverride().configureHelp({ formatHelp: mockProgramHelp });202- const mockSubHelp = jest.fn();203- sub.exitOverride().configureHelp({ formatHelp: mockSubHelp });195+ describe('help', () => {196+ const cases = [197+ { args: [], programHelp: 0, subHelp: 0 },198+ { args: ['--help'], programHelp: 1, subHelp: 0 },199+ { args: ['help'], programHelp: 1, subHelp: 0 },200+ ];201 202+ for (const { args, programHelp, subHelp } of cases) {203+ test(`when user args ${JSON.stringify(args)} then program/sub help called ${programHelp}/${subHelp}`, (t) => {204+ const { program, sub } = makeProgram();205+ const mockProgramHelp = t.mock.fn();206+ program.exitOverride().configureHelp({ formatHelp: mockProgramHelp });207+ const mockSubHelp = t.mock.fn();208+ sub.exitOverride().configureHelp({ formatHelp: mockSubHelp });209+205- try {206- program.parse(userArgs, { from: 'user' });207- } catch (err) {208- /* empty */209- }210- expect(mockProgramHelp).toHaveBeenCalledTimes(expectProgramHelpCount);211- expect(mockSubHelp).toHaveBeenCalledTimes(expectSubHelpCount);212- },213- );210+ try {211+ program.parse(args, { from: 'user' });212+ } catch (err) {213+ /* empty */214+ }215+ assert.equal(mockProgramHelp.mock.callCount(), programHelp);216+ assert.equal(mockSubHelp.mock.callCount(), subHelp);217+ });218+ }219+ });220 });221 222 // ------------------------------------------------------------------------------223 16 unmodified lines240 241 test('when option before command-argument then option parsed', () => {242 const { program, sub } = makeProgram();243 program.parse(['sub', '--debug', 'arg'], { from: 'user' });238- expect(sub.args).toEqual(['arg']);239- expect(sub.opts().debug).toBe(true);244+ assert.deepEqual(sub.args, ['arg']);245+ assert.equal(sub.opts().debug, true);246 });247 248 test('when known option after command-argument then option passed through', () => {249 const { program, sub } = makeProgram();250 program.parse(['sub', 'arg', '--debug'], { from: 'user' });245- expect(sub.args).toEqual(['arg', '--debug']);246- expect(sub.opts().debug).toBeUndefined();251+ assert.deepEqual(sub.args, ['arg', '--debug']);252+ assert.equal(sub.opts().debug, undefined);253 });254 255 test('when unknown option after command-argument then option passed through', () => {256 const { program, sub } = makeProgram();257 program.parse(['sub', 'arg', '--pass'], { from: 'user' });252- expect(sub.args).toEqual(['arg', '--pass']);258+ assert.deepEqual(sub.args, ['arg', '--pass']);259 });260 255- test('when action handler and unknown option after command-argument then option passed through', () => {261+ test('when action handler and unknown option after command-argument then option passed through', (t) => {262 const { program, sub } = makeProgram();257- const mockAction = jest.fn();263+ const mockAction = t.mock.fn();264 sub.action(mockAction);265 program.parse(['sub', 'arg', '--pass'], { from: 'user' });260- expect(mockAction).toHaveBeenCalledWith(['arg', '--pass'], sub.opts(), sub);266+ assert.equal(mockAction.mock.callCount(), 1);267+ const callArgs = mockAction.mock.calls[0].arguments;268+ assert.deepEqual(callArgs[0], ['arg', '--pass']);269 });270 271 test('when help option after command-argument then option passed through', () => {272 const { program, sub } = makeProgram();273 program.parse(['sub', 'arg', '--help'], { from: 'user' });266- expect(sub.args).toEqual(['arg', '--help']);274+ assert.deepEqual(sub.args, ['arg', '--help']);275 });276 277 test('when version option after command-argument then option passed through', () => {278 const { program, sub } = makeProgram();279 program.version('1.2.3');280 program.parse(['sub', 'arg', '--version'], { from: 'user' });273- expect(sub.args).toEqual(['arg', '--version']);281+ assert.deepEqual(sub.args, ['arg', '--version']);282 });283 284 test('when shared option before sub and after sub and after sub parameter then all three parsed', () => {285 const { program, sub } = makeProgram();286 program.parse(287 ['--shared=global', 'sub', '--shared=local', 'arg', '--shared'],288 { from: 'user' },289 );282- expect(program.opts().shared).toEqual('global');283- expect(sub.opts().shared).toEqual('local');284- expect(sub.args).toEqual(['arg', '--shared']);290+ assert.equal(program.opts().shared, 'global');291+ assert.equal(sub.opts().shared, 'local');292+ assert.deepEqual(sub.args, ['arg', '--shared']);293 });294 });295 296 // ------------------------------------------------------------------------------13 unmodified lines310 311 test('when option before command-argument then option parsed', () => {312 const { program, sub } = makeProgram();313 program.parse(['--debug', 'arg'], { from: 'user' });306- expect(sub.args).toEqual(['arg']);307- expect(sub.opts().debug).toBe(true);314+ assert.deepEqual(sub.args, ['arg']);315+ assert.equal(sub.opts().debug, true);316 });317 318 test('when known option after command-argument then option passed through', () => {319 const { program, sub } = makeProgram();320 program.parse(['arg', '--debug'], { from: 'user' });313- expect(sub.args).toEqual(['arg', '--debug']);314- expect(sub.opts().debug).toBeUndefined();321+ assert.deepEqual(sub.args, ['arg', '--debug']);322+ assert.equal(sub.opts().debug, undefined);323 });324 325 test('when unknown option after command-argument then option passed through', () => {326 const { program, sub } = makeProgram();327 program.parse(['arg', '--pass'], { from: 'user' });320- expect(sub.args).toEqual(['arg', '--pass']);328+ assert.deepEqual(sub.args, ['arg', '--pass']);329 });330 323- test('when action handler and unknown option after command-argument then option passed through', () => {331+ test('when action handler and unknown option after command-argument then option passed through', (t) => {332 const { program, sub } = makeProgram();325- const mockAction = jest.fn();333+ const mockAction = t.mock.fn();334 sub.action(mockAction);335 program.parse(['arg', '--pass'], { from: 'user' });328- expect(mockAction).toHaveBeenCalledWith(['arg', '--pass'], sub.opts(), sub);336+ assert.equal(mockAction.mock.callCount(), 1);337+ const callArgs = mockAction.mock.calls[0].arguments;338+ assert.deepEqual(callArgs[0], ['arg', '--pass']);339 });340 });341 342 // ------------------------------------------------------------------------------15 unmodified lines358 359 test('when global option before parameter then global option parsed', () => {360 const { program } = makeProgram();361 program.parse(['--global', 'foo'], { from: 'user' });352- expect(program.opts().global).toBe(true);362+ assert.equal(program.opts().global, true);363 });364 365 test('when global option after parameter then global option parsed', () => {366 const { program } = makeProgram();367 program.parse(['foo', '--global'], { from: 'user' });358- expect(program.opts().global).toBe(true);368+ assert.equal(program.opts().global, true);369 });370 371 test('when global option after parameter with same name as subcommand then global option parsed', () => {372 const { program } = makeProgram();373 program.parse(['foo', 'sub', '--global'], { from: 'user' });364- expect(program.opts().global).toBe(true);374+ assert.equal(program.opts().global, true);375 });376 });377 378 // ------------------------------------------------------------------------------2 unmodified lines381 test('when program not positional and turn on passThroughOptions in subcommand then error', () => {382 const program = new commander.Command();383 const sub = program.command('sub');384 375- expect(() => {385+ assert.throws(() => {386 sub.passThroughOptions();377- }).toThrow();387+ });388 });389 390 test('when program not positional and add subcommand with passThroughOptions then error', () => {391 const program = new commander.Command();392 const sub = new commander.Command('sub').passThroughOptions();393 384- expect(() => {394+ assert.throws(() => {395 program.addCommand(sub);386- }).toThrow();396+ });397 });398 });399 400 // ------------------------------------------------------------------------------17 unmodified lines418 419 test('when global option before parameter then global option parsed', () => {420 const { program } = makeProgram();421 program.parse(['--global', 'foo'], { from: 'user' });412- expect(program.opts().global).toBe(true);422+ assert.equal(program.opts().global, true);423 });424 425 test('when global option after parameter then passed through', () => {426 const { program } = makeProgram();427 program.parse(['foo', '--global'], { from: 'user' });418- expect(program.args).toEqual(['foo', '--global']);428+ assert.deepEqual(program.args, ['foo', '--global']);429 });430 431 test('when subcommand option after subcommand then option parsed', () => {432 const { program, sub } = makeProgram();433 program.parse(['sub', '--debug'], { from: 'user' });424- expect(sub.opts().debug).toBe(true);434+ assert.equal(sub.opts().debug, true);435 });436 437 // This is somewhat of a side-effect of supporting previous test.438 test('when shared option after subcommand then parsed by subcommand', () => {439 const { program, sub } = makeProgram();440 program.parse(['sub', '-g'], { from: 'user' });431- expect(sub.opts().group).toBe(true);432- expect(program.opts().global).toBeUndefined();441+ assert.equal(sub.opts().group, true);442+ assert.equal(program.opts().global, undefined);443 });444 });445 446 // ------------------------------------------------------------------------------4 unmodified lines451 program.passThroughOptions().allowUnknownOption().option('--debug');452 program.argument('[args...]');453 454 program.parse(['--unknown', '--debug'], { from: 'user' });445- expect(program.args).toEqual(['--unknown', '--debug']);455+ assert.deepEqual(program.args, ['--unknown', '--debug']);456 });457 458 test('when positionalOptions and unknown option then known options then known option parsed', () => {459 const program = new commander.Command();460 program.enablePositionalOptions().allowUnknownOption().option('--debug');461 program.argument('[args...]');462 463 program.parse(['--unknown', '--debug'], { from: 'user' });454- expect(program.opts().debug).toBe(true);455- expect(program.args).toEqual(['--unknown']);464+ assert.equal(program.opts().debug, true);465+ assert.deepEqual(program.args, ['--unknown']);466 });467 });468 469 // ------------------------------------------------------------------------------8 unmodified lines478 test('when passThroughOptions() then option passed through', () => {479 const program = makeProgram();480 program.passThroughOptions();481 program.parse(['foo', '--debug'], { from: 'user' });472- expect(program.args).toEqual(['foo', '--debug']);482+ assert.deepEqual(program.args, ['foo', '--debug']);483 });484 485 test('when passThroughOptions(true) then option passed through', () => {486 const program = makeProgram();487 program.passThroughOptions(true);488 program.parse(['foo', '--debug'], { from: 'user' });479- expect(program.args).toEqual(['foo', '--debug']);489+ assert.deepEqual(program.args, ['foo', '--debug']);490 });491 492 test('when passThroughOptions(false) then option parsed', () => {493 const program = makeProgram();494 program.passThroughOptions(false);495 program.parse(['foo', '--debug'], { from: 'user' });486- expect(program.args).toEqual(['foo']);487- expect(program.opts().debug).toEqual(true);496+ assert.deepEqual(program.args, ['foo']);497+ assert.equal(program.opts().debug, true);498 });499 });500 501 // ------------------------------------------------------------------------------9 unmodified lines511 test('when enablePositionalOptions() then option parsed by subcommand', () => {512 const { program, sub } = makeProgram();513 program.enablePositionalOptions();514 program.parse(['sub', '--debug'], { from: 'user' });505- expect(sub.opts().debug).toEqual(true);515+ assert.equal(sub.opts().debug, true);516 });517 518 test('when enablePositionalOptions(true) then option parsed by subcommand', () => {519 const { program, sub } = makeProgram();520 program.enablePositionalOptions(true);521 program.parse(['sub', '--debug'], { from: 'user' });512- expect(sub.opts().debug).toEqual(true);522+ assert.equal(sub.opts().debug, true);523 });524 525 test('when enablePositionalOptions(false) then option parsed by program', () => {526 const { program, sub } = makeProgram();527 program.enablePositionalOptions(false);528 program.parse(['sub', '--debug'], { from: 'user' });519- expect(sub.opts().debug).toBeUndefined();520- expect(program.opts().debug).toEqual(true);529+ assert.equal(sub.opts().debug, undefined);530+ assert.equal(program.opts().debug, true);531 });532 });modified:tests/command.registerClash.test.js+50 added-30 removed
1 const { Command } = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when command name conflicts with existing name then throw', () => {4- expect(() => {5- const program = new Command();6- program.command('one');7- program.command('one');8- }).toThrow('cannot add command');6+ assert.throws(7+ () => {8+ const program = new Command();9+ program.command('one');10+ program.command('one');11+ },12+ { message: /cannot add command/ },13+ );14 });15 16 test('when command name conflicts with existing alias then throw', () => {17+ assert.throws(12- expect(() => {13- const program = new Command();14- program.command('one').alias('1');15- program.command('1');16- }).toThrow('cannot add command');18+ () => {19+ const program = new Command();20+ program.command('one').alias('1');21+ program.command('1');22+ },23+ { message: /cannot add command/ },24+ );25 });26 27 test('when command alias conflicts with existing name then throw', () => {28+ assert.throws(20- expect(() => {21- const program = new Command();22- program.command('one');23- program.command('1').alias('one');24- }).toThrow('cannot add alias');29+ () => {30+ const program = new Command();31+ program.command('one');32+ program.command('1').alias('one');33+ },34+ { message: /cannot add alias/ },35+ );36 });37 38 test('when command alias conflicts with existing alias then throw', () => {28- expect(() => {29- const program = new Command();30- program.command('one').alias('1');31- program.command('unity').alias('1');32- }).toThrow('cannot add alias');39+ assert.throws(40+ () => {41+ const program = new Command();42+ program.command('one').alias('1');43+ program.command('unity').alias('1');44+ },45+ { message: /cannot add alias/ },46+ );47 });48 49 test('when .addCommand name conflicts with existing name then throw', () => {50+ assert.throws(36- expect(() => {37- const program = new Command();38- program.command('one');39- program.addCommand(new Command('one'));40- }).toThrow('cannot add command');51+ () => {52+ const program = new Command();53+ program.command('one');54+ program.addCommand(new Command('one'));55+ },56+ { message: /cannot add command/ },57+ );58 });59 60 test('when .addCommand alias conflicts with existing name then throw', () => {61+ assert.throws(44- expect(() => {45- const program = new Command();46- program.command('one');47- program.addCommand(new Command('unity').alias('one'));48- }).toThrow('cannot add command');62+ () => {63+ const program = new Command();64+ program.command('one');65+ program.addCommand(new Command('unity').alias('one'));66+ },67+ { message: /cannot add command/ },68+ );69 });modified:tests/command.showHelpAfterError.test.js+91 added-74 removed
1 const commander = require('../');2+const { test, describe, mock } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('showHelpAfterError with message', () => {6 const customHelpMessage = 'See --help';7 6- function makeProgram() {7- const writeMock = jest.fn();8+ function makeProgram(t) {9+ const writeMock = t.mock.fn();10 const program = new commander.Command();11 program12 .exitOverride()13 .showHelpAfterError(customHelpMessage)1 unmodified line15 16 return { program, writeMock };17 }18 17- test('when missing command-argument then shows help', () => {18- const { program, writeMock } = makeProgram();19+ test('when missing command-argument then shows help', (t) => {20+ const { program, writeMock } = makeProgram(t);21 program.argument('<file>');20- let caughtErr;21- try {22- program.parse([], { from: 'user' });23- } catch (err) {24- caughtErr = err;25- }26- expect(caughtErr.code).toBe('commander.missingArgument');27- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);22+ assert.throws(23+ () => {24+ program.parse([], { from: 'user' });25+ },26+ {27+ code: 'commander.missingArgument',28+ },29+ );30+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];31+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);32 });33 30- test('when missing option-argument then shows help', () => {31- const { program, writeMock } = makeProgram();34+ test('when missing option-argument then shows help', (t) => {35+ const { program, writeMock } = makeProgram(t);36 program.option('--output <file>');33- let caughtErr;34- try {35- program.parse(['--output'], { from: 'user' });36- } catch (err) {37- caughtErr = err;38- }39- expect(caughtErr.code).toBe('commander.optionMissingArgument');40- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);37+ assert.throws(38+ () => {39+ program.parse(['--output'], { from: 'user' });40+ },41+ {42+ code: 'commander.optionMissingArgument',43+ },44+ );45+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];46+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);47 });48 43- test('when missing mandatory option then shows help', () => {44- const { program, writeMock } = makeProgram();49+ test('when missing mandatory option then shows help', (t) => {50+ const { program, writeMock } = makeProgram(t);51 program.requiredOption('--password <cipher>');46- let caughtErr;47- try {48- program.parse([], { from: 'user' });49- } catch (err) {50- caughtErr = err;51- }52- expect(caughtErr.code).toBe('commander.missingMandatoryOptionValue');53- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);52+ assert.throws(53+ () => {54+ program.parse([], { from: 'user' });55+ },56+ {57+ code: 'commander.missingMandatoryOptionValue',58+ },59+ );60+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];61+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);62 });63 56- test('when unknown option then shows help', () => {57- const { program, writeMock } = makeProgram();58- let caughtErr;59- try {60- program.parse(['--unknown-option'], { from: 'user' });61- } catch (err) {62- caughtErr = err;63- }64- expect(caughtErr.code).toBe('commander.unknownOption');65- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);64+ test('when unknown option then shows help', (t) => {65+ const { program, writeMock } = makeProgram(t);66+ assert.throws(67+ () => {68+ program.parse(['--unknown-option'], { from: 'user' });69+ },70+ {71+ code: 'commander.unknownOption',72+ },73+ );74+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];75+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);76 });77 68- test('when too many command-arguments then shows help', () => {69- const { program, writeMock } = makeProgram();78+ test('when too many command-arguments then shows help', (t) => {79+ const { program, writeMock } = makeProgram(t);80 program.allowExcessArguments(false);71- let caughtErr;72- try {73- program.parse(['surprise'], { from: 'user' });74- } catch (err) {75- caughtErr = err;76- }77- expect(caughtErr.code).toBe('commander.excessArguments');78- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);81+ assert.throws(82+ () => {83+ program.parse(['surprise'], { from: 'user' });84+ },85+ {86+ code: 'commander.excessArguments',87+ },88+ );89+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];90+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);91 });92 81- test('when unknown command then shows help', () => {82- const { program, writeMock } = makeProgram();93+ test('when unknown command then shows help', (t) => {94+ const { program, writeMock } = makeProgram(t);95 program.command('sub1');84- let caughtErr;85- try {86- program.parse(['sub2'], { from: 'user' });87- } catch (err) {88- caughtErr = err;89- }90- expect(caughtErr.code).toBe('commander.unknownCommand');91- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);96+ assert.throws(97+ () => {98+ program.parse(['sub2'], { from: 'user' });99+ },100+ {101+ code: 'commander.unknownCommand',102+ },103+ );104+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];105+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);106 });107 94- test('when invalid option choice then shows help', () => {95- const { program, writeMock } = makeProgram();108+ test('when invalid option choice then shows help', (t) => {109+ const { program, writeMock } = makeProgram(t);110 program.addOption(new commander.Option('--color').choices(['red', 'blue']));97- let caughtErr;98- try {99- program.parse(['--color', 'pink'], { from: 'user' });100- } catch (err) {101- caughtErr = err;102- }103- expect(caughtErr.code).toBe('commander.invalidArgument');104- expect(writeMock).toHaveBeenLastCalledWith(`${customHelpMessage}\n`);111+ assert.throws(112+ () => {113+ program.parse(['--color', 'pink'], { from: 'user' });114+ },115+ {116+ code: 'commander.invalidArgument',117+ },118+ );119+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];120+ assert.equal(lastCall.arguments[0], `${customHelpMessage}\n`);121 });122 });123 124 test('when showHelpAfterError() and error and then shows full help', () => {109- const writeMock = jest.fn();125+ const writeMock = mock.fn();126 const program = new commander.Command();127 program128 .exitOverride()129 .showHelpAfterError()3 unmodified lines133 program.parse(['--unknown-option'], { from: 'user' });134 } catch (err) {135 /* empty */136 }121- expect(writeMock).toHaveBeenLastCalledWith(program.helpInformation());137+ const lastCall = writeMock.mock.calls[writeMock.mock.calls.length - 1];138+ assert.equal(lastCall.arguments[0], program.helpInformation());139 });modified:tests/command.showSuggestionAfterError.test.js+6 added-4 removed
1 const { Command } = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 function getSuggestion(program, arg) {6 let message = '';7 program.exitOverride().configureOutput({16 unmodified lines24 const program = new Command();25 program.showSuggestionAfterError();26 program.command('example');27 const suggestion = getSuggestion(program, 'exampel');26- expect(suggestion).toBe('example');28+ assert.equal(suggestion, 'example');29 });30 31 test('when unknown command and showSuggestionAfterError(false) then do not show suggestion', () => {32 const program = new Command();33 program.showSuggestionAfterError(false);34 program.command('example');35 const suggestion = getSuggestion(program, 'exampel');34- expect(suggestion).toBe(null);36+ assert.equal(suggestion, null);37 });38 39 test('when unknown option and showSuggestionAfterError() then show suggestion', () => {40 const program = new Command();41 program.showSuggestionAfterError();42 program.option('--example');43 const suggestion = getSuggestion(program, '--exampel');42- expect(suggestion).toBe('--example');44+ assert.equal(suggestion, '--example');45 });46 47 test('when unknown option and showSuggestionAfterError(false) then do not show suggestion', () => {48 const program = new Command();49 program.showSuggestionAfterError(false);50 program.option('--example');51 const suggestion = getSuggestion(program, '--exampel');50- expect(suggestion).toBe(null);52+ assert.equal(suggestion, null);53 });modified:tests/command.summary.test.js+3 added-1 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when set summary then get summary', () => {6 const program = new commander.Command();7 const summary = 'abcdef';8 program.summary(summary);7- expect(program.summary()).toMatch(summary);9+ assert.equal(program.summary(), summary);10 });modified:tests/command.unknownCommand.test.js+30 added-48 removed
1-const commander = require('../');1+const { createTestCommand } = require('./testHelpers');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('unknownCommand', () => {4- // Optional. Use internal knowledge to suppress output to keep test output clean.5- let writeErrorSpy;6-7- beforeAll(() => {8- writeErrorSpy = jest9- .spyOn(process.stderr, 'write')10- .mockImplementation(() => {});11- });12-13- afterEach(() => {14- writeErrorSpy.mockClear();15- });16-17- afterAll(() => {18- writeErrorSpy.mockRestore();19- });20-6 test('when unknown argument in simple program then error', () => {22- const program = new commander.Command();23- program.exitOverride();24- expect(() => {7+ const program = createTestCommand();8+ assert.throws(() => {9 program.parse('node test.js unknown'.split(' '));26- }).toThrow();10+ });11 });12 13 test('when unknown command but action handler taking arg then no error', () => {30- const program = new commander.Command();31- program.exitOverride().command('sub');14+ const program = createTestCommand();15+ program.command('sub');16 program.argument('[args...]').action(() => {});33- expect(() => {17+ assert.doesNotThrow(() => {18 program.parse('node test.js unknown'.split(' '));35- }).not.toThrow();19+ });20 });21 22 test('when unknown command but listener then no error', () => {39- const program = new commander.Command();40- program.exitOverride().command('sub');23+ const program = createTestCommand();24+ program.command('sub');25 program.on('command:*', () => {});42- expect(() => {26+ assert.doesNotThrow(() => {27 program.parse('node test.js unknown'.split(' '));44- }).not.toThrow();28+ });29 });30 31 test('when unknown command then error', () => {48- const program = new commander.Command();49- program.exitOverride().command('sub');50- let caughtErr;51- try {52- program.parse('node test.js unknown'.split(' '));53- } catch (err) {54- caughtErr = err;55- }56- expect(caughtErr.code).toBe('commander.unknownCommand');32+ const program = createTestCommand();33+ program.command('sub');34+ assert.throws(35+ () => {36+ program.parse('node test.js unknown'.split(' '));37+ },38+ { code: 'commander.unknownCommand' },39+ );40 });41 42 test('when unknown command and unknown option then error is for unknown command', () => {43 // The unknown command is more useful since the option is for an unknown command (and might be44 // ok if the command had been correctly spelled, say).62- const program = new commander.Command();63- program.exitOverride().command('sub');64- let caughtErr;65- try {66- program.parse('node test.js sbu --silly'.split(' '));67- } catch (err) {68- caughtErr = err;69- }70- expect(caughtErr.code).toBe('commander.unknownCommand');45+ const program = createTestCommand();46+ program.command('sub');47+ assert.throws(48+ () => {49+ program.parse('node test.js sbu --silly'.split(' '));50+ },51+ { code: 'commander.unknownCommand' },52+ );53 });54 });modified:tests/command.unknownOption.test.js+49 added-84 removed
1-const commander = require('../');1+const { createTestCommand } = require('./testHelpers');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Checking for detection of unknown options, including regression tests for some past issues.6 7 describe('unknownOption', () => {6- // Optional. Use internal knowledge to suppress output to keep test output clean.7- let writeErrorSpy;8-9- beforeAll(() => {10- writeErrorSpy = jest11- .spyOn(process.stderr, 'write')12- .mockImplementation(() => {});13- });14-15- afterEach(() => {16- writeErrorSpy.mockClear();17- });18-19- afterAll(() => {20- writeErrorSpy.mockRestore();21- });22-8 test('when specify unknown option with subcommand and action handler then error', () => {24- const program = new commander.Command();25- program26- .exitOverride()27- .command('info')28- .action(() => {});9+ const program = createTestCommand();10+ program.command('info').action(() => {});11 30- let caughtErr;31- try {32- program.parse(['node', 'test', 'info', '--NONSENSE']);33- } catch (err) {34- caughtErr = err;35- }36- expect(caughtErr.code).toBe('commander.unknownOption');12+ assert.throws(13+ () => {14+ program.parse(['node', 'test', 'info', '--NONSENSE']);15+ },16+ { code: 'commander.unknownOption' },17+ );18 });19 20 test('when specify unknown option with subcommand argument and action handler then error', () => {40- const program = new commander.Command();41- program42- .exitOverride()43- .command('info <file>')44- .action(() => {});21+ const program = createTestCommand();22+ program.command('info <file>').action(() => {});23 46- let caughtErr;47- try {48- program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);49- } catch (err) {50- caughtErr = err;51- }52- expect(caughtErr.code).toBe('commander.unknownOption');24+ assert.throws(25+ () => {26+ program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);27+ },28+ { code: 'commander.unknownOption' },29+ );30 });31 32 test('when specify unknown option with program and action handler then error', () => {56- const program = new commander.Command();57- program58- .exitOverride()59- .argument('[file]')60- .action(() => {});33+ const program = createTestCommand();34+ program.argument('[file]').action(() => {});35 62- let caughtErr;63- try {64- program.parse(['node', 'test', '--NONSENSE']);65- } catch (err) {66- caughtErr = err;67- }68- expect(caughtErr.code).toBe('commander.unknownOption');36+ assert.throws(37+ () => {38+ program.parse(['node', 'test', '--NONSENSE']);39+ },40+ { code: 'commander.unknownOption' },41+ );42 });43 44 test('when specify unknown option with program argument and action handler then error', () => {45 // Regression test from #96573- const program = new commander.Command();74- program75- .exitOverride()76- .argument('[file]')77- .action(() => {});46+ const program = createTestCommand();47+ program.argument('[file]').action(() => {});48 79- let caughtErr;80- try {81- program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);82- } catch (err) {83- caughtErr = err;84- }85- expect(caughtErr.code).toBe('commander.unknownOption');49+ assert.throws(50+ () => {51+ program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);52+ },53+ { code: 'commander.unknownOption' },54+ );55 });56 57 test('when specify unknown option with simple program then error', () => {89- const program = new commander.Command();90- program.exitOverride();91- let caughtErr;92- try {93- program.parse(['node', 'test', '--NONSENSE']);94- } catch (err) {95- caughtErr = err;96- }97- expect(caughtErr.code).toBe('commander.unknownOption');58+ const program = createTestCommand();59+ assert.throws(60+ () => {61+ program.parse(['node', 'test', '--NONSENSE']);62+ },63+ { code: 'commander.unknownOption' },64+ );65 });66 67 test('when specify unknown global option before subcommand then error', () => {101- const program = new commander.Command();102- program.exitOverride();68+ const program = createTestCommand();69 program.command('sub');70 105- let caughtErr;106- try {107- program.parse(['--NONSENSE', 'sub'], { from: 'user' });108- } catch (err) {109- caughtErr = err;110- }111- expect(caughtErr.code).toBe('commander.unknownOption');71+ assert.throws(72+ () => {73+ program.parse(['--NONSENSE', 'sub'], { from: 'user' });74+ },75+ { code: 'commander.unknownOption' },76+ );77 });78 });modified:tests/command.usage.test.js+12 added-10 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when default usage and check program help then starts with default usage', () => {6 const program = new commander.Command();7 8 program.name('test');9 const helpInformation = program.helpInformation();10 9- expect(helpInformation).toMatch(/^Usage: test \[options\]/);11+ assert.match(helpInformation, /^Usage: test \[options\]/);12 });13 14 test('when custom usage and check program help then starts with custom usage', () => {15 const myUsage = 'custom';2 unmodified lines18 19 program.name('test');20 const helpInformation = program.helpInformation();21 20- expect(helpInformation).toMatch(new RegExp(`^Usage: test ${myUsage}`));22+ assert.match(helpInformation, new RegExp(`^Usage: test ${myUsage}`));23 });24 25 test('when default usage and check subcommand help then starts with default usage including program name', () => {26 const program = new commander.Command();1 unmodified line28 29 program.name('test');30 const helpInformation = subCommand.helpInformation();31 30- expect(helpInformation).toMatch(/^Usage: test info \[options\]/);32+ assert.match(helpInformation, /^Usage: test info \[options\]/);33 });34 35 test('when custom usage and check subcommand help then starts with custom usage including program name', () => {36 const myUsage = 'custom';2 unmodified lines39 40 program.name('test');41 const helpInformation = subCommand.helpInformation();42 41- expect(helpInformation).toMatch(new RegExp(`^Usage: test info ${myUsage}`));43+ assert.match(helpInformation, new RegExp(`^Usage: test info ${myUsage}`));44 });45 46 test('when has option then [options] included in usage', () => {47 const program = new commander.Command();48 49 program.option('--foo');50 49- expect(program.usage()).toMatch('[options]');51+ assert.match(program.usage(), /\[options\]/);52 });53 54 test('when no options then [options] not included in usage', () => {55 const program = new commander.Command();56 57 program.helpOption(false);58 57- expect(program.usage()).not.toMatch('[options]');59+ assert.doesNotMatch(program.usage(), /\[options\]/);60 });61 62 test('when has command then [command] included in usage', () => {63 const program = new commander.Command();64 65 program.command('foo');66 65- expect(program.usage()).toMatch('[command]');67+ assert.match(program.usage(), /\[command\]/);68 });69 70 test('when no commands then [command] not included in usage', () => {71 const program = new commander.Command();72 71- expect(program.usage()).not.toMatch('[command]');73+ assert.doesNotMatch(program.usage(), /\[command\]/);74 });75 76 test('when argument then argument included in usage', () => {77 const program = new commander.Command();78 79 program.argument('<file>');80 79- expect(program.usage()).toMatch('<file>');81+ assert.match(program.usage(), /<file>/);82 });83 84 test('when options and command and argument then all three included in usage', () => {85 const program = new commander.Command();86 87 program.argument('<file>').option('--alpha').command('beta');88 87- expect(program.usage()).toEqual('[options] [command] <file>');89+ assert.equal(program.usage(), '[options] [command] <file>');90 });modified:tests/commander.configureCommand.test.js+32 added-21 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Mostly testing direct on program, limited check that (sub)command working same.6 7 // Default behaviours1 unmodified line9 test('when default then options not stored on command', () => {10 const program = new commander.Command();11 program.option('--foo <value>', 'description');12 program.parse(['node', 'test', '--foo', 'bar']);11- expect(program.foo).toBeUndefined();12- expect(program.opts().foo).toBe('bar');13+ assert.equal(program.foo, undefined);14+ assert.equal(program.opts().foo, 'bar');15 });16 15-test('when default then options+command passed to action', () => {17+test('when default then options+command passed to action', (t) => {18 const program = new commander.Command();17- const callback = jest.fn();19+ const callback = t.mock.fn();20 program.argument('<value>').action(callback);21 program.parse(['node', 'test', 'value']);20- expect(callback).toHaveBeenCalledWith('value', program.opts(), program);22+ const callArgs = callback.mock.calls[0].arguments;23+ assert.equal(callArgs[0], 'value');24+ assert.equal(callArgs[1], program.opts());25+ assert.equal(callArgs[2], program);26 });27 28 // storeOptionsAsProperties29 30 test('when storeOptionsAsProperties() then options stored on command', () => {31 const program = new commander.Command();32 program.storeOptionsAsProperties().option('--foo <value>', 'description');33 program.parse(['node', 'test', '--foo', 'bar']);29- expect(program.foo).toBe('bar');30- expect(program.opts().foo).toBe('bar');34+ assert.equal(program.foo, 'bar');35+ assert.equal(program.opts().foo, 'bar');36 });37 38 test('when storeOptionsAsProperties(true) then options stored on command', () => {39 const program = new commander.Command();40 program.storeOptionsAsProperties(true).option('--foo <value>', 'description');41 program.parse(['node', 'test', '--foo', 'bar']);37- expect(program.foo).toBe('bar');38- expect(program.opts().foo).toBe('bar');42+ assert.equal(program.foo, 'bar');43+ assert.equal(program.opts().foo, 'bar');44 });45 46 test('when storeOptionsAsProperties(false) then options not stored on command', () => {47 const program = new commander.Command();48 program49 .storeOptionsAsProperties(false)50 .option('--foo <value>', 'description');51 program.parse(['node', 'test', '--foo', 'bar']);47- expect(program.foo).toBeUndefined();48- expect(program.opts().foo).toBe('bar');52+ assert.equal(program.foo, undefined);53+ assert.equal(program.opts().foo, 'bar');54 });55 51-test('when storeOptionsAsProperties() then command+command passed to action', () => {56+test('when storeOptionsAsProperties() then command+command passed to action', (t) => {57 const program = new commander.Command();53- const callback = jest.fn();58+ const callback = t.mock.fn();59 program.storeOptionsAsProperties().argument('<value>').action(callback);60 program.parse(['node', 'test', 'value']);56- expect(callback).toHaveBeenCalledWith('value', program, program);61+ const callArgs = callback.mock.calls[0].arguments;62+ assert.equal(callArgs[0], 'value');63+ assert.equal(callArgs[1], program);64+ assert.equal(callArgs[2], program);65 });66 59-test('when storeOptionsAsProperties(false) then opts+command passed to action', () => {67+test('when storeOptionsAsProperties(false) then opts+command passed to action', (t) => {68 const program = new commander.Command();61- const callback = jest.fn();69+ const callback = t.mock.fn();70 program.storeOptionsAsProperties(false).argument('<value>').action(callback);71 program.parse(['node', 'test', 'value']);64- expect(callback).toHaveBeenCalledWith('value', program.opts(), program);72+ const callArgs = callback.mock.calls[0].arguments;73+ assert.equal(callArgs[0], 'value');74+ assert.equal(callArgs[1], program.opts());75+ assert.equal(callArgs[2], program);76 });77 78 test('when storeOptionsAsProperties() after adding option then throw', () => {79 const program = new commander.Command();80 program.option('--port <number>', 'port number', '80');70- expect(() => {81+ assert.throws(() => {82 program.storeOptionsAsProperties();72- }).toThrow();83+ });84 });85 86 test('when storeOptionsAsProperties() after setting option value then throw', () => {87 const program = new commander.Command();88 program.setOptionValue('foo', 'bar');78- expect(() => {89+ assert.throws(() => {90 program.storeOptionsAsProperties();80- }).toThrow();91+ });92 });modified:tests/createCommand.test.js+6 added-4 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when createCommand then unattached', () => {6 const program = new commander.Command();7 const cmd = program.createCommand();6- expect(program.commands.length).toBe(0);7- expect(cmd.parent).toBeFalsy(); // (actually null, but use weaker test for unattached)8+ assert.equal(program.commands.length, 0);9+ assert.equal(cmd.parent, null);10 });11 12 test('when subclass overrides createCommand then subcommand is subclass', () => {13 class MyClass extends commander.Command {7 unmodified lines21 }22 }23 const program = new MyClass();24 const sub = program.command('sub');23- expect(sub.myProperty).toEqual('myClass');25+ assert.equal(sub.myProperty, 'myClass');26 });27 28 test('when override createCommand then subcommand is custom', () => {29 function createCustom(name) {3 unmodified lines33 }34 const program = createCustom();35 program.createCommand = createCustom;36 const sub = program.command('sub');35- expect(sub.myProperty).toEqual('custom');37+ assert.equal(sub.myProperty, 'custom');38 });modified:tests/deprecated.test.js+5 added-3 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test for backwards compatible behaviour of deprecated features that don't fit in elsewhere.6 // We keep deprecated features working (when not too difficult) to avoid breaking existing code7 // and reduce barriers to updating to latest version of Commander.2 unmodified lines10 test('when option not given then value is default', () => {11 const program = new commander.Command();12 program.option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');13 program.parse([], { from: 'user' });12- expect(program.opts().cheese).toEqual('mild');14+ assert.equal(program.opts().cheese, 'mild');15 });16 17 test('when argument matches regexp then value is as specified', () => {18 const program = new commander.Command();19 program.option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');20 program.parse(['--cheese', 'tasty'], { from: 'user' });19- expect(program.opts().cheese).toEqual('tasty');21+ assert.equal(program.opts().cheese, 'tasty');22 });23 24 test('when argument does not match regexp then value is default', () => {25 const program = new commander.Command();26 program.option('--cheese <type>', 'cheese type', /mild|tasty/, 'mild');27 program.parse(['--cheese', 'other'], { from: 'user' });26- expect(program.opts().cheese).toEqual('mild');28+ assert.equal(program.opts().cheese, 'mild');29 });30 });deleted:tests/esm-imports-test.mjs-51 removed
1-import {2- program,3- Command,4- Option,5- Argument,6- CommanderError,7- InvalidArgumentError,8- InvalidOptionArgumentError,9- Help,10- createCommand,11- createArgument,12- createOption,13-} from '../esm.mjs';14-15-// Do some simple checks that expected imports are available at runtime.16-// Run using `npm run test-esm`.17-// Similar tests to test-imports.test.ts18-19-function check(condition, explanation) {20- if (!condition) {21- console.log(`Failed assertion: ${explanation}`);22- process.exit(2);23- }24-}25-26-function checkClass(obj, name) {27- console.log(`Checking ${name}`);28- check(typeof obj === 'object', `new ${name}() produces object`);29- check(obj.constructor.name === name, `object constructor is ${name}`);30-}31-32-console.log('Checking program');33-check(typeof program === 'object', 'program is object');34-check(program.constructor.name === 'Command', 'program is class Command');35-36-checkClass(new Command(), 'Command');37-checkClass(new Option('-e, --example'), 'Option');38-checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');39-checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');40-checkClass(new InvalidOptionArgumentError('failed'), 'InvalidArgumentError');41-checkClass(new Help(), 'Help');42-checkClass(new Argument('<file>'), 'Argument');43-44-console.log('Checking createCommand');45-check(typeof createCommand === 'function', 'createCommand is function');46-console.log('Checking createArgument');47-check(typeof createArgument === 'function', 'createArgument is function');48-console.log('Checking createOption');49-check(typeof createOption === 'function', 'createOption is function');50-51-console.log('No problems');modified:tests/help.argumentDescription.test.js+9 added-7 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 7 describe('argumentDescription', () => {8 test('when argument has no description then empty string', () => {9 const argument = new commander.Argument('[n]');10 const helper = new commander.Help();9- expect(helper.argumentDescription(argument)).toEqual('');11+ assert.equal(helper.argumentDescription(argument), '');12 });13 14 test('when argument has description then return description', () => {15 const description = 'description';16 const argument = new commander.Argument('[n]', description);17 const helper = new commander.Help();16- expect(helper.argumentDescription(argument)).toEqual(description);18+ assert.equal(helper.argumentDescription(argument), description);19 });20 21 test('when argument has default value then return description and default value', () => {22 const argument = new commander.Argument('[n]', 'description').default(23 'default',24 );25 const helper = new commander.Help();24- expect(helper.argumentDescription(argument)).toEqual(26+ assert.equal(27+ helper.argumentDescription(argument),28 'description (default: "default")',29 );30 });31 2 unmodified lines34 'default value',35 'custom',36 );37 const helper = new commander.Help();35- expect(helper.argumentDescription(argument)).toEqual(38+ assert.equal(39+ helper.argumentDescription(argument),40 'description (default: custom)',41 );42 });43 44 test('when an argument has default value and no description then still return default value', () => {45 const argument = new commander.Argument('[n]').default('default');46 const helper = new commander.Help();43- expect(helper.argumentDescription(argument)).toEqual(44- '(default: "default")',45- );47+ assert.equal(helper.argumentDescription(argument), '(default: "default")');48 });49 });modified:tests/help.boxWrap.test.js+22 added-19 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when empty string then return empty string', () => {6 const helper = new commander.Help();7 const text = '';8 const wrapped = helper.boxWrap(text, 50);7- expect(wrapped).toEqual(text);9+ assert.equal(wrapped, text);10 });11 12 test('when string contains unix line breaks then return (unix) empty lines', () => {13 const helper = new commander.Help();14 const text = '\n\n\n';15 const wrapped = helper.boxWrap(text, 50);14- expect(wrapped).toEqual(text);16+ assert.equal(wrapped, text);17 });18 19 test('when string contains Windows line breaks then return (unix)) empty lines', () => {20 const helper = new commander.Help();21 const text = '\r\n\r\n\r\n';22 const wrapped = helper.boxWrap(text, 50);21- expect(wrapped).toEqual('\n\n\n');23+ assert.equal(wrapped, '\n\n\n');24 });25 26 test('when string contains only whitespace then returns empty string (trim right)', () => {27 const helper = new commander.Help();28 const text = ' \t ';29 const wrapped = helper.boxWrap(text, 50);28- expect(wrapped).toEqual('');30+ assert.equal(wrapped, '');31 });32 33 test('when string contains leading whitespace then returns string with leading whitespace', () => {34 const helper = new commander.Help();35 const text = ' abc';36 const wrapped = helper.boxWrap(text, 50);35- expect(wrapped).toEqual(' abc');37+ assert.equal(wrapped, ' abc');38 });39 40 test('when string contains intermediate whitespace then returns string with intermediate whitespace', () => {41 const helper = new commander.Help();42 const text = '123 456';43 const wrapped = helper.boxWrap(text, 50);42- expect(wrapped).toEqual('123 456');44+ assert.equal(wrapped, '123 456');45 });46 47 test('when string contains trailing whitespace then returns string without trailing whitespace (trim right)', () => {48 const helper = new commander.Help();49 const text = '123 456 ';50 const wrapped = helper.boxWrap(text, 50);49- expect(wrapped).toEqual('123 456');51+ assert.equal(wrapped, '123 456');52 });53 54 test('when string contains escape sequences then returns string with escape sequences', () => {55 const helper = new commander.Help();56 const text = '123 456 ';57 const wrapped = helper.boxWrap(text, 50);56- expect(wrapped).toEqual('123 456');58+ assert.equal(wrapped, '123 456');59 });60 61 test('when string has enough words to wrap then returns two wrapped lines', () => {62 const helper = new commander.Help();63 const text = '123 567 901 345 789 123 567 901 345 789 123 567 901';64 const wrapped = helper.boxWrap(text, 45);63- expect(wrapped).toEqual(64- '123 567 901 345 789 123 567 901 345 789 123\n567 901',65- );65+ assert.equal(wrapped, '123 567 901 345 789 123 567 901 345 789 123\n567 901');66 });67 68 test('when string has enough words and escape sequences to wrap then returns wrapped line with break ignoring escape sequences', () => {69 const helper = new commander.Help();70 const CSI = '\u001b[';71 const underlinedText = `${CSI}4mXYZ${CSI}24m`;72 const text = `${underlinedText}${' ABC'.repeat(19)}`;73 const wrapped = helper.boxWrap(text, 44);74+ assert.equal(75+ wrapped,74- expect(wrapped).toEqual(`${underlinedText} ${'ABC '.repeat(9)}ABC75-${'ABC '.repeat(8)}ABC`);76+ `${underlinedText} ${'ABC '.repeat(9)}ABC77+${'ABC '.repeat(8)}ABC`,78+ );79 });80 81 test('when first word longer than width then soft wrap', () => {82 const helper = new commander.Help();83 const text = 'abc'.repeat(20);84 const wrapped = helper.boxWrap(text, 40);82- expect(wrapped).toEqual(text);85+ assert.equal(wrapped, text);86 });87 88 test('when second word longer than width then wrap and soft wrap', () => {89 const helper = new commander.Help();90 const text = 'xyz ' + 'abc'.repeat(20);91 const wrapped = helper.boxWrap(text, 40);89- expect(wrapped).toEqual(`xyz\n${'abc'.repeat(20)}`);92+ assert.equal(wrapped, `xyz\n${'abc'.repeat(20)}`);93 });94 95 test('when set width 41 then wrap at 41', () => {96 const helper = new commander.Help();97 const text = 'X'.repeat(39) + ' 1 2 3';98 let wrapped = helper.boxWrap(text, 40);96- expect(wrapped).toEqual('X'.repeat(39) + '\n1 2 3');99+ assert.equal(wrapped, 'X'.repeat(39) + '\n1 2 3');100 wrapped = helper.boxWrap(text, 41);98- expect(wrapped).toEqual('X'.repeat(39) + ' 1\n2 3');101+ assert.equal(wrapped, 'X'.repeat(39) + ' 1\n2 3');102 });103 104 test('when set width 12 (too small) then skip wrap', () => {105 const helper = new commander.Help();106 const text = ' x'.repeat(8) + ' yy'.repeat(6);107 let wrapped = helper.boxWrap(text, 14);105- expect(wrapped).toEqual(text);108+ assert.equal(wrapped, text);109 });110 111 test('when set width 12 (and set minWrapWidth) then skip wrap', () => {112 const helper = new commander.Help();113 helper.minWidthToWrap = 1;114 const text = ' x'.repeat(8) + ' yy'.repeat(6);115 let wrapped = helper.boxWrap(text, 14);113- expect(wrapped).toEqual(' x x x x x x x\nx yy yy yy yy\nyy yy');116+ assert.equal(wrapped, ' x x x x x x x\nx yy yy yy yy\nyy yy');117 });modified:tests/help.commandTerm.test.js+8 added-5 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 1 unmodified line9 describe('subcommandTerm', () => {10 test('when plain command then returns name', () => {11 const command = new commander.Command('program');12 const helper = new commander.Help();11- expect(helper.subcommandTerm(command)).toEqual('program');13+ assert.equal(helper.subcommandTerm(command), 'program');14 });15 16 test('when command has alias then returns name|alias', () => {17 const command = new commander.Command('program').alias('alias');18 const helper = new commander.Help();17- expect(helper.subcommandTerm(command)).toEqual('program|alias');19+ assert.equal(helper.subcommandTerm(command), 'program|alias');20 });21 22 test('when command has options then returns name [options]', () => {23 const command = new commander.Command('program').option('-a,--all');24 const helper = new commander.Help();23- expect(helper.subcommandTerm(command)).toEqual('program [options]');25+ assert.equal(helper.subcommandTerm(command), 'program [options]');26 });27 28 test('when command has <argument> then returns name <argument>', () => {29 const command = new commander.Command('program').argument('<argument>');30 const helper = new commander.Help();29- expect(helper.subcommandTerm(command)).toEqual('program <argument>');31+ assert.equal(helper.subcommandTerm(command), 'program <argument>');32 });33 34 test('when command has everything then returns name|alias [options] <argument>', () => {35 const command = new commander.Command('program')36 .alias('alias')37 .option('-a,--all')38 .argument('<argument>');39 const helper = new commander.Help();38- expect(helper.subcommandTerm(command)).toEqual(40+ assert.equal(41+ helper.subcommandTerm(command),42 'program|alias [options] <argument>',43 );44 });45 });modified:tests/help.commandUsage.test.js+7 added-5 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 1 unmodified line9 test('when single program then "program [options]"', () => {10 const program = new commander.Command();11 program.name('program');12 const helper = new commander.Help();11- expect(helper.commandUsage(program)).toEqual('program [options]');13+ assert.equal(helper.commandUsage(program), 'program [options]');14 });15 16 test('when multi program then "program [options] [command]"', () => {17 const program = new commander.Command();18 program.name('program');19 program.command('sub');20 const helper = new commander.Help();19- expect(helper.commandUsage(program)).toEqual('program [options] [command]');21+ assert.equal(helper.commandUsage(program), 'program [options] [command]');22 });23 24 test('when program has alias then usage includes alias', () => {25 const program = new commander.Command();26 program.name('program').alias('alias');27 const helper = new commander.Help();26- expect(helper.commandUsage(program)).toEqual('program|alias [options]');28+ assert.equal(helper.commandUsage(program), 'program|alias [options]');29 });30 31 test('when help for subcommand then usage includes hierarchy', () => {32 const program = new commander.Command();33 program.name('program');34 const sub = program.command('sub').name('sub');35 const helper = new commander.Help();34- expect(helper.commandUsage(sub)).toEqual('program sub [options]');36+ assert.equal(helper.commandUsage(sub), 'program sub [options]');37 });38 39 test('when program has argument then usage includes argument', () => {40 const program = new commander.Command();41 program.name('program').argument('<file>');42 const helper = new commander.Help();41- expect(helper.commandUsage(program)).toEqual('program [options] <file>');43+ assert.equal(helper.commandUsage(program), 'program [options] <file>');44 });45 });modified:tests/help.longestArgumentTermLength.test.js+7 added-3 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 8 describe('longestArgumentTermLength', () => {9 test('when no arguments then returns zero', () => {10 const program = new commander.Command();11 const helper = new commander.Help();10- expect(helper.longestArgumentTermLength(program, helper)).toEqual(0);12+ assert.equal(helper.longestArgumentTermLength(program, helper), 0);13 });14 15 test('when has argument description then returns argument length', () => {16 const program = new commander.Command();17 program.argument('<wonder>', 'wonder description');18 const helper = new commander.Help();17- expect(helper.longestArgumentTermLength(program, helper)).toEqual(19+ assert.equal(20+ helper.longestArgumentTermLength(program, helper),21 'wonder'.length,22 );23 });24 2 unmodified lines27 program.argument('<alpha>', 'x');28 program.argument('<longest>', 'x');29 program.argument('<beta>', 'x');30 const helper = new commander.Help();28- expect(helper.longestArgumentTermLength(program, helper)).toEqual(31+ assert.equal(32+ helper.longestArgumentTermLength(program, helper),33 'longest'.length,34 );35 });36 });modified:tests/help.longestCommandTermLength.test.js+11 added-5 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 8 describe('longestSubcommandTermLength', () => {9 test('when no commands then returns zero', () => {10 const program = new commander.Command();11 const helper = new commander.Help();10- expect(helper.longestSubcommandTermLength(program, helper)).toEqual(0);12+ assert.equal(helper.longestSubcommandTermLength(program, helper), 0);13 });14 15 test('when command and no help then returns length of term', () => {16 const sub = new commander.Command('sub');17 const program = new commander.Command();18 program.addHelpCommand(false).addCommand(sub);19 const helper = new commander.Help();18- expect(helper.longestSubcommandTermLength(program, helper)).toEqual(20+ assert.equal(21+ helper.longestSubcommandTermLength(program, helper),22 helper.subcommandTerm(sub).length,23 );24 });25 1 unmodified line27 const sub = new commander.Command('sub <file)');28 const program = new commander.Command();29 program.addHelpCommand(false).addCommand(sub);30 const helper = new commander.Help();28- expect(helper.longestSubcommandTermLength(program, helper)).toEqual(31+ assert.equal(32+ helper.longestSubcommandTermLength(program, helper),33 helper.subcommandTerm(sub).length,34 );35 });36 5 unmodified lines42 .command('before', 'desc')43 .command(longestCommandName, 'desc')44 .command('after', 'desc');45 const helper = new commander.Help();42- expect(helper.longestSubcommandTermLength(program, helper)).toEqual(46+ assert.equal(47+ helper.longestSubcommandTermLength(program, helper),48 longestCommandName.length,49 );50 });51 52 test('when just help command then returns length of help term', () => {53 const program = new commander.Command();54 program.addHelpCommand(true);55 const helper = new commander.Help();51- expect(helper.longestSubcommandTermLength(program, helper)).toEqual(56+ assert.equal(57+ helper.longestSubcommandTermLength(program, helper),58 'help [command]'.length,59 );60 });61 });modified:tests/help.longestOptionTermLength.test.js+7 added-3 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 1 unmodified line9 test('when no option then returns zero', () => {10 const program = new commander.Command();11 program.helpOption(false);12 const helper = new commander.Help();11- expect(helper.longestOptionTermLength(program, helper)).toEqual(0);13+ assert.equal(helper.longestOptionTermLength(program, helper), 0);14 });15 16 test('when just implicit help option returns length of help flags', () => {17 const program = new commander.Command();18 const helper = new commander.Help();17- expect(helper.longestOptionTermLength(program, helper)).toEqual(19+ assert.equal(20+ helper.longestOptionTermLength(program, helper),21 '-h, --help'.length,22 );23 });24 4 unmodified lines29 .option('--before', 'optional description of flags')30 .option(longestOptionFlags)31 .option('--after');32 const helper = new commander.Help();30- expect(helper.longestOptionTermLength(program, helper)).toEqual(33+ assert.equal(34+ helper.longestOptionTermLength(program, helper),35 longestOptionFlags.length,36 );37 });38 });modified:tests/help.minWidthToWrap.test.js+5 added-3 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('Help.minWidthToWrap', () => {6 test('when enough width then wrap', () => {7 const program = new commander.Command('program');7 unmodified lines15 '\n' +16 'x '.repeat(50).trim() +17 '\n' +18 'x '.repeat(10).trim();17- expect(helpText).toMatch(wrappedescription);19+ assert.match(helpText, new RegExp(wrappedescription));20 });21 22 test('when not enough width then no wrap', () => {23 const program = new commander.Command('program');2 unmodified lines26 getOutHelpWidth: () => 30, // too narrow to wrap27 });28 const helpText = program.helpInformation();29 const wrappedescription = 'x '.repeat(50);28- expect(helpText).toMatch(wrappedescription);30+ assert.match(helpText, new RegExp(wrappedescription));31 });32 33 test('when make minWidthToWrap small then wrap', () => {34 const program = new commander.Command('program');8 unmodified lines43 '\n' +44 'x '.repeat(15).trimEnd() +45 '\n' +46 'x '.repeat(10).trimEnd();45- expect(helpText).toMatch(wrappedescription);47+ assert.match(helpText, new RegExp(wrappedescription));48 });49 });modified:tests/help.optionDescription.test.js+17 added-10 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 8 describe('optionDescription', () => {9 test('when option has no description then empty string', () => {10 const option = new commander.Option('-a');11 const helper = new commander.Help();10- expect(helper.optionDescription(option)).toEqual('');12+ assert.equal(helper.optionDescription(option), '');13 });14 15 test('when option has description then return description', () => {16 const description = 'description';17 const option = new commander.Option('-a', description);18 const helper = new commander.Help();17- expect(helper.optionDescription(option)).toEqual(description);19+ assert.equal(helper.optionDescription(option), description);20 });21 22 test('when boolean option has default value true then return description and default value', () => {23 const description = 'description';24 const option = new commander.Option('-a', description).default(true);25 const helper = new commander.Help();24- expect(helper.optionDescription(option)).toEqual(26+ assert.equal(27+ helper.optionDescription(option),28 'description (default: true)',29 );30 });31 32 test('when boolean option has default value string then return description without default', () => {33 const description = 'description';34 const option = new commander.Option('-a', description).default('foo');35 const helper = new commander.Help();33- expect(helper.optionDescription(option)).toEqual('description');36+ assert.equal(helper.optionDescription(option), 'description');37 });38 39 test('when optional option has preset value then return description and default value', () => {40 const description = 'description';41 const option = new commander.Option('--aa [value]', description).preset(42 'abc',43 );44 const helper = new commander.Help();42- expect(helper.optionDescription(option)).toEqual(45+ assert.equal(46+ helper.optionDescription(option),47 'description (preset: "abc")',48 );49 });50 51 test('when boolean option has preset value then return description without default', () => {52 const description = 'description';53 const option = new commander.Option('--bb', description).preset('abc');54 const helper = new commander.Help();51- expect(helper.optionDescription(option)).toEqual('description');55+ assert.equal(helper.optionDescription(option), 'description');56 });57 test('when option has env then return description and env name', () => {58 const description = 'description';59 const option = new commander.Option('-a', description).env('ENV');60 const helper = new commander.Help();57- expect(helper.optionDescription(option)).toEqual('description (env: ENV)');61+ assert.equal(helper.optionDescription(option), 'description (env: ENV)');62 });63 64 test('when option has default value description then return description and custom default description', () => {65 const description = 'description';2 unmodified lines68 'default value',69 defaultValueDescription,70 );71 const helper = new commander.Help();68- expect(helper.optionDescription(option)).toEqual(72+ assert.equal(73+ helper.optionDescription(option),74 `description (default: ${defaultValueDescription})`,75 );76 });77 3 unmodified lines81 'default value',82 defaultValueDescription,83 );84 const helper = new commander.Help();80- expect(helper.optionDescription(option)).toEqual(85+ assert.equal(86+ helper.optionDescription(option),87 `(default: ${defaultValueDescription})`,88 );89 });90 3 unmodified lines94 const option = new commander.Option('-a <value>', description).choices(95 choices,96 );97 const helper = new commander.Help();92- expect(helper.optionDescription(option)).toEqual(98+ assert.equal(99+ helper.optionDescription(option),100 'description (choices: "one", "two")',101 );102 });103 });modified:tests/help.optionTerm.test.js+6 added-4 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 1 unmodified line9 test('when -s flags then returns flags', () => {10 const flags = '-s';11 const option = new commander.Option(flags);12 const helper = new commander.Help();11- expect(helper.optionTerm(option)).toEqual(flags);13+ assert.equal(helper.optionTerm(option), flags);14 });15 16 test('when --short flags then returns flags', () => {17 const flags = '--short';18 const option = new commander.Option(flags);19 const helper = new commander.Help();18- expect(helper.optionTerm(option)).toEqual(flags);20+ assert.equal(helper.optionTerm(option), flags);21 });22 23 test('when -s,--short flags then returns flags', () => {24 const flags = '-s,--short';25 const option = new commander.Option(flags);26 const helper = new commander.Help();25- expect(helper.optionTerm(option)).toEqual(flags);27+ assert.equal(helper.optionTerm(option), flags);28 });29 30 test('when -s|--short flags then returns flags', () => {31 const flags = '-s|--short';32 const option = new commander.Option(flags);33 const helper = new commander.Help();32- expect(helper.optionTerm(option)).toEqual(flags);34+ assert.equal(helper.optionTerm(option), flags);35 });36 });modified:tests/help.padWidth.test.js+6 added-4 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 3 unmodified lines11 const program = new commander.Command();12 program.argument(`<${longestThing}>`, 'description').option('-o');13 program.command('sub');14 const helper = new commander.Help();13- expect(helper.padWidth(program, helper)).toEqual(longestThing.length);15+ assert.equal(helper.padWidth(program, helper), longestThing.length);16 });17 18 test('when option term longest return option length', () => {19 const longestThing = '--very-long-thing-bigger-than-others';20 const program = new commander.Command();21 program.argument('<file>', 'desc').option(longestThing);22 program.command('sub');23 const helper = new commander.Help();22- expect(helper.padWidth(program, helper)).toEqual(longestThing.length);24+ assert.equal(helper.padWidth(program, helper), longestThing.length);25 });26 27 test('when global option term longest return global option length', () => {28 const longestThing = '--very-long-thing-bigger-than-others';3 unmodified lines32 .option(longestThing)33 .configureHelp({ showGlobalOptions: true });34 const sub = program.command('sub');35 const helper = sub.createHelp();34- expect(helper.padWidth(sub, helper)).toEqual(longestThing.length);36+ assert.equal(helper.padWidth(sub, helper), longestThing.length);37 });38 39 test('when command term longest return command length', () => {40 const longestThing = 'very-long-thing-bigger-than-others';41 const program = new commander.Command();42 program.argument('<file>', 'desc').option('-o');43 program.command(longestThing);44 const helper = new commander.Help();43- expect(helper.padWidth(program, helper)).toEqual(longestThing.length);45+ assert.equal(helper.padWidth(program, helper), longestThing.length);46 });47 });modified:tests/help.preformatted.test.js+11 added-9 removed
1 const { Help, Command } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('preformatted', () => {6 test('when single line then false', () => {7 const helper = new Help();6- expect(helper.preformatted('a b c')).toBe(false);8+ assert.equal(helper.preformatted('a b c'), false);9 });10 11 test('when single line with leading whitespace then false', () => {12 const helper = new Help();11- expect(helper.preformatted(' a b c')).toBe(false);13+ assert.equal(helper.preformatted(' a b c'), false);14 });15 16 test('when unix line break not followed by whitespace then false', () => {17 const helper = new Help();16- expect(helper.preformatted('a\nb\nc')).toBe(false);18+ assert.equal(helper.preformatted('a\nb\nc'), false);19 });20 21 test('when Windows line break not followed by whitespace then false', () => {22 const helper = new Help();21- expect(helper.preformatted('a\r\nb\r\nc')).toBe(false);23+ assert.equal(helper.preformatted('a\r\nb\r\nc'), false);24 });25 26 test('when unix line followed by whitespace then true', () => {27 const helper = new Help();26- expect(helper.preformatted('a\n b')).toBe(true);28+ assert.equal(helper.preformatted('a\n b'), true);29 });30 31 test('when Windows line break followed by whitespace then true', () => {32 const helper = new Help();31- expect(helper.preformatted('a\r\n b')).toBe(true);33+ assert.equal(helper.preformatted('a\r\n b'), true);34 });35 36 test('when empty unix lines then false', () => {37 const helper = new Help();36- expect(helper.preformatted('a\n\n')).toBe(false);38+ assert.equal(helper.preformatted('a\n\n'), false);39 });40 41 test('when empty Windows lines then false', () => {42 const helper = new Help();41- expect(helper.preformatted('a\r\n\r\n')).toBe(false);43+ assert.equal(helper.preformatted('a\r\n\r\n'), false);44 });45 });46 47 test('end-to-end: when option description is preformatted then manual format is preserved', () => {19 unmodified lines67 68 -h, --help display help for command69 `;70 69- expect(program.helpInformation()).toBe(expectedOutput);71+ assert.equal(program.helpInformation(), expectedOutput);72 });modified:tests/help.showGlobalOptions.test.js+13 added-15 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when default configuration then global options hidden', () => {6 const program = new commander.Command();7 program.option('--global');8 const sub = program.command('sub');7- expect(sub.helpInformation()).not.toContain('global');9+ assert.doesNotMatch(sub.helpInformation(), /global/);10 });11 12 test('when showGlobalOptions:true then program options shown', () => {13 const program = new commander.Command();14 program.option('--global').configureHelp({ showGlobalOptions: true });15 const sub = program.command('sub');14- expect(sub.helpInformation()).toContain('global');16+ assert.match(sub.helpInformation(), /global/);17 });18 19 test('when showGlobalOptions:true and no global options then global options header not shown', () => {20 const program = new commander.Command();21 program.configureHelp({ showGlobalOptions: true });22 const sub = program.command('sub');21- expect(sub.helpInformation()).not.toContain('Global');23+ assert.doesNotMatch(sub.helpInformation(), /Global/);24 });25 26 test('when showGlobalOptions:true and nested commands then combined nested options shown program last', () => {27 const program = new commander.Command();28 program.option('--global').configureHelp({ showGlobalOptions: true });29 const sub1 = program.command('sub1').option('--sub1');30 const sub2 = sub1.command('sub2');29- expect(sub2.helpInformation()).toContain(`Global Options:30- --sub131- --global32-`);31+ assert.match(32+ sub2.helpInformation(),33+ /Global Options:\n {2}--sub1\n {2}--global\n/,34+ );35 });36 37 test('when showGlobalOptions:true and sortOptions: true then global options sorted', () => {38 const program = new commander.Command();3 unmodified lines42 .option('-2')43 .configureHelp({ showGlobalOptions: true, sortOptions: true });44 const sub1 = program.command('sub1').option('-6').option('-1').option('-5');45 const sub2 = sub1.command('sub2');44- expect(sub2.helpInformation()).toContain(`Global Options:45- -146- -247- -348- -449- -550- -651-`);46+ assert.match(47+ sub2.helpInformation(),48+ /Global Options:\n {2}-1\n {2}-2\n {2}-3\n {2}-4\n {2}-5\n {2}-6\n/,49+ );50 });modified:tests/help.sortCommands.test.js+4 added-2 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 7 unmodified lines15 const helper = program.createHelp();16 const visibleCommandNames = helper17 .visibleCommands(program)18 .map((cmd) => cmd.name());17- expect(visibleCommandNames).toEqual(['ccc', 'aaa', 'bbb', 'help']);19+ assert.deepEqual(visibleCommandNames, ['ccc', 'aaa', 'bbb', 'help']);20 });21 22 test('when sortSubcommands:true then commands sorted', () => {23 const program = new commander.Command();5 unmodified lines29 const helper = program.createHelp();30 const visibleCommandNames = helper31 .visibleCommands(program)32 .map((cmd) => cmd.name());31- expect(visibleCommandNames).toEqual(['aaa', 'bbb', 'ccc', 'help']);33+ assert.deepEqual(visibleCommandNames, ['aaa', 'bbb', 'ccc', 'help']);34 });35 });modified:tests/help.sortOptions.test.js+14 added-6 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).7 7 unmodified lines15 const helper = program.createHelp();16 const visibleOptionNames = helper17 .visibleOptions(program)18 .map((option) => option.name());17- expect(visibleOptionNames).toEqual(['zzz', 'aaa', 'bbb', 'help']);19+ assert.deepEqual(visibleOptionNames, ['zzz', 'aaa', 'bbb', 'help']);20 });21 22 test('when sortOptions:true then options sorted alphabetically', () => {23 const program = new commander.Command();5 unmodified lines29 const helper = program.createHelp();30 const visibleOptionNames = helper31 .visibleOptions(program)32 .map((cmd) => cmd.name());31- expect(visibleOptionNames).toEqual(['aaa', 'bbb', 'help', 'zzz']);33+ assert.deepEqual(visibleOptionNames, ['aaa', 'bbb', 'help', 'zzz']);34 });35 36 test('when both short and long flags then sort on short flag', () => {37 const program = new commander.Command();5 unmodified lines43 const helper = program.createHelp();44 const visibleOptionNames = helper45 .visibleOptions(program)46 .map((cmd) => cmd.name());45- expect(visibleOptionNames).toEqual(['help', 'zzz', 'aaa', 'bbb']);47+ assert.deepEqual(visibleOptionNames, ['help', 'zzz', 'aaa', 'bbb']);48 });49 50 test('when lone short and long flags then sort on lone flag', () => {51 const program = new commander.Command();5 unmodified lines57 const helper = program.createHelp();58 const visibleOptionNames = helper59 .visibleOptions(program)60 .map((cmd) => cmd.name());59- expect(visibleOptionNames).toEqual(['aaa', 'b', 'help', 'zzz']);61+ assert.deepEqual(visibleOptionNames, ['aaa', 'b', 'help', 'zzz']);62 });63 64 test('when mixed case flags then sort is case insensitive', () => {65 const program = new commander.Command();5 unmodified lines71 const helper = program.createHelp();72 const visibleOptionNames = helper73 .visibleOptions(program)74 .map((cmd) => cmd.name());73- expect(visibleOptionNames).toEqual(['a', 'B', 'c', 'help']);75+ assert.deepEqual(visibleOptionNames, ['a', 'B', 'c', 'help']);76 });77 78 test('when negated option then sort negated option separately', () => {79 const program = new commander.Command();6 unmodified lines86 const helper = program.createHelp();87 const visibleOptionNames = helper88 .visibleOptions(program)89 .map((cmd) => cmd.name());88- expect(visibleOptionNames).toEqual(['aaa', 'bbb', 'ccc', 'help', 'no-bbb']);90+ assert.deepEqual(visibleOptionNames, [91+ 'aaa',92+ 'bbb',93+ 'ccc',94+ 'help',95+ 'no-bbb',96+ ]);97 });98 });modified:tests/help.stripAnsi.test.js+13 added-11 removed
1 const { stripColor } = require('../lib/help');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters6 7 // Test the lowest level routine being used for SGR support.2 unmodified lines10 const CSI = ESC + '[';11 12 test('SGR only', () => {13 const str = `${CSI}4m`;12- expect(stripColor(str)).toEqual('');14+ assert.equal(stripColor(str), '');15 });16 17 test('SGR at start', () => {18 const str = `${CSI}4mX`;17- expect(stripColor(str)).toEqual('X');19+ assert.equal(stripColor(str), 'X');20 });21 22 test('SGR in middle', () => {23 const str = `X${CSI}4mY`;22- expect(stripColor(str)).toEqual('XY');24+ assert.equal(stripColor(str), 'XY');25 });26 27 test('SGR at end', () => {28 const str = `${CSI}4mY`;27- expect(stripColor(str)).toEqual('Y');29+ assert.equal(stripColor(str), 'Y');30 });31 32 test('SGR pair', () => {33 // underline and not underlined34 const str = `${CSI}4mABC${CSI}24m`;33- expect(stripColor(str)).toEqual('ABC');35+ assert.equal(stripColor(str), 'ABC');36 });37 38 test('explicit reset with zero', () => {39 const str = `${CSI}0m`;38- expect(stripColor(str)).toEqual('');40+ assert.equal(stripColor(str), '');41 });42 43 test('implicit reset without zero', () => {44 const str = `${CSI}m`;43- expect(stripColor(str)).toEqual('');45+ assert.equal(stripColor(str), '');46 });47 48 test('multiple params: select foreground colour', () => {49 const str = `${CSI}38;5;4m`;48- expect(stripColor(str)).toEqual('');50+ assert.equal(stripColor(str), '');51 });52 53 test('multiple params: general', () => {54 const str = `${CSI}2;3;4m`;53- expect(stripColor(str)).toEqual('');55+ assert.equal(stripColor(str), '');56 });57 58 test('multiple params: missing param', () => {59 // CSI sequences can omit number (which is then treated as 0)60 const str = `${CSI};;m`;59- expect(stripColor(str)).toEqual('');61+ assert.equal(stripColor(str), '');62 });63 64 test('incomplete SGR sequence', () => {65 const str = `${CSI}14X`;64- expect(stripColor(str)).toEqual(`${CSI}14X`);66+ assert.equal(stripColor(str), `${CSI}14X`);67 });modified:tests/help.style.test.js+34 added-18 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const { Command } = require('../');4 5 function red(str) {4- // Use plain characters so not stripped in Jest failure messages. (Means displayWidth is bogus though.)6+ // Use plain characters so not stripped in failure messages. (Means displayWidth is bogus though.)7 return `RED ${str} DER`;8 }9 function stripRed(str) {10 return str.replace(/RED /g, '').replace(/ DER/g, '');25 unmodified lines36 test('styleTitle', () => {37 const program = makeProgram();38 program.configureHelp({ styleTitle: (str) => red(str) }, displayWidth);39 const helpText = program.helpInformation();38- expect(helpText).toEqual(40+ assert.equal(41+ helpText,42 plainHelpInformation43 .replace('Usage:', red('Usage:'))44 .replace('Arguments:', red('Arguments:'))45 .replace('Options:', red('Options:'))5 unmodified lines51 const program = makeProgram();52 program.configureHelp({ styleUsage: (str) => red(str), displayWidth });53 const helpText = program.helpInformation();54 const usageString = program.createHelp().commandUsage(program);52- expect(helpText).toEqual(55+ assert.equal(56+ helpText,57 plainHelpInformation.replace(usageString, red(usageString)),58 );59 });60 3 unmodified lines64 styleCommandDescription: (str) => red(str),65 displayWidth,66 });67 const helpText = program.helpInformation();64- expect(helpText).toEqual(68+ assert.equal(69+ helpText,70 plainHelpInformation.replace(71 'program description',72 red('program description'),73 ),6 unmodified lines80 styleOptionDescription: (str) => red(str),81 displayWidth,82 });83 const helpText = program.helpInformation();79- expect(helpText).toEqual(84+ assert.equal(85+ helpText,86 plainHelpInformation.replace(87 /(-h, --help *)(display help for command)/,88 (match, p1, p2) => p1 + red(p2),89 ),6 unmodified lines96 styleSubcommandDescription: (str) => red(str),97 displayWidth,98 });99 const helpText = program.helpInformation();94- expect(helpText).toEqual(100+ assert.equal(101+ helpText,102 plainHelpInformation103 .replace(104 /(\[subarg\] *)(sub description)/,105 (match, p1, p2) => p1 + red(p2),11 unmodified lines117 styleArgumentDescription: (str) => red(str),118 displayWidth,119 });120 const helpText = program.helpInformation();114- expect(helpText).toEqual(121+ assert.equal(122+ helpText,123 plainHelpInformation.replace('arg description', red('arg description')),124 );125 });126 3 unmodified lines130 styleDescriptionText: (str) => red(str),131 displayWidth,132 });133 const helpText = program.helpInformation();126- expect(helpText).toEqual(134+ assert.equal(135+ helpText,136 plainHelpInformation137 .replace('program description', red('program description'))138 .replace('arg description', red('arg description'))139 .replace('sub description', red('sub description'))4 unmodified lines144 test('styleOptionTerm', () => {145 const program = makeProgram();146 program.configureHelp({ styleOptionTerm: (str) => red(str), displayWidth });147 const helpText = program.helpInformation();139- expect(helpText).toEqual(148+ assert.equal(149+ helpText,150 plainHelpInformation.replace('-h, --help', red('-h, --help')),151 );152 });153 3 unmodified lines157 styleSubcommandTerm: (str) => red(str),158 displayWidth,159 });160 const helpText = program.helpInformation();151- expect(helpText).toEqual(161+ assert.equal(162+ helpText,163 plainHelpInformation164 .replace('help [command]', red('help [command]'))165 .replace(166 'subcommand [options] [subarg]',8 unmodified lines175 styleArgumentTerm: (str) => red(str),176 displayWidth,177 });178 const helpText = program.helpInformation();168- expect(helpText).toEqual(179+ assert.equal(180+ helpText,181 plainHelpInformation.replace(' file ', ` ${red('file')} `),182 );183 });184 3 unmodified lines188 styleOptionText: (str) => red(str),189 displayWidth,190 });191 const helpText = program.helpInformation();180- expect(helpText).toEqual(192+ assert.equal(193+ helpText,194 plainHelpInformation195 .replace(/\[options\]/g, red('[options]'))196 .replace('-h, --help', red('-h, --help')),197 );5 unmodified lines203 styleArgumentText: (str) => red(str),204 displayWidth,205 });206 const helpText = program.helpInformation();194- expect(helpText).toEqual(207+ assert.equal(208+ helpText,209 plainHelpInformation210 .replace('<file>', red('<file>'))211 .replace(' file ', ` ${red('file')} `)212 .replace('[subarg]', red('[subarg]'))7 unmodified lines220 styleSubcommandText: (str) => red(str),221 displayWidth,222 });223 const helpText = program.helpInformation();210- expect(helpText).toEqual(224+ assert.equal(225+ helpText,226 plainHelpInformation227 .replace('[command] <file>', `${red('[command]')} <file>`)228 .replace('help [command]', `${red('help')} [command]`)229 .replace('subcommand', red('subcommand')),6 unmodified lines236 styleCommandText: (str) => red(str),237 displayWidth,238 });239 const helpText = program.helpInformation();225- expect(helpText).toEqual(240+ assert.equal(241+ helpText,242 plainHelpInformation.replace('program', red('program')),243 );244 });245 });23 unmodified lines269 test('when getOutHasColors returns true then help has color', () => {270 const program = makeProgram(true);271 program.outputHelp();272 const helpText = program.myHelpText.join('');257- expect(helpText).toMatch(red('program'));273+ assert.match(helpText, new RegExp(red('program')));274 });275 276 test('when getOutHasColors returns false then help does not have color', () => {277 const program = makeProgram(false);278 program.outputHelp();279 const helpText = program.myHelpText.join('');264- expect(helpText).not.toMatch(red('program'));280+ assert.doesNotMatch(helpText, new RegExp(red('program')));281 });282 283 test('when getOutHasColors returns false then style still called', () => {284 const program = makeProgram(true);5 unmodified lines290 return red(str);291 };292 program.configureHelp(config);293 program.outputHelp();278- expect(styleCalled).toBe(true);294+ assert.equal(styleCalled, true);295 });296 });modified:tests/help.subcommandDescription.test.js+6 added-4 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).1 unmodified line8 describe('subcommandDescription', () => {9 test('when program has no summary or description then empty string', () => {10 const program = new commander.Command();11 const helper = new commander.Help();10- expect(helper.subcommandDescription(program)).toEqual('');12+ assert.equal(helper.subcommandDescription(program), '');13 });14 15 test('when program has summary then return summary', () => {16 const summary = 'summary';17 const program = new commander.Command();18 program.summary(summary);19 const helper = new commander.Help();18- expect(helper.subcommandDescription(program)).toEqual(summary);20+ assert.equal(helper.subcommandDescription(program), summary);21 });22 23 test('when program has description then return description', () => {24 const description = 'description';25 const program = new commander.Command();26 program.description(description);27 const helper = new commander.Help();26- expect(helper.subcommandDescription(program)).toEqual(description);28+ assert.equal(helper.subcommandDescription(program), description);29 });30 31 test('when program has summary and description then return summary', () => {32 const summary = 'summary';33 const program = new commander.Command();34 program.summary(summary);35 program.description('description');36 const helper = new commander.Help();35- expect(helper.subcommandDescription(program)).toEqual(summary);37+ assert.equal(helper.subcommandDescription(program), summary);38 });39 });modified:tests/help.suggestion.test.js+105 added-96 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const { Command, Option } = require('../');4 5 // Note: setting up shared command configuration in getSuggestion,6 // and looking for possible subcommand 'sub'.23 unmodified lines30 const match = message.match(/Did you mean (one of )?(.*)\?/);31 return match ? match[2] : null;32 }33 34+describe('command suggestions', () => {32-test.each([33- ['yyy', ['zzz'], null, 'none similar'],34- ['a', ['b'], null, 'one edit away but not similar'],35- ['a', ['ab'], 'ab', 'one edit away'],36- ['ab', ['a'], null, 'one edit away'],37- ['at', ['cat'], 'cat', '1 insertion'],38- ['cat', ['at'], 'at', '1 deletion'],39- ['bat', ['cat'], 'cat', '1 substitution'],40- ['act', ['cat'], 'cat', '1 transposition'],41- ['cxx', ['cat'], null, '2 edits away and short string'],42- ['caxx', ['cart'], 'cart', '2 edits away and longer string'],43- [44- '1234567',45- ['1234567890'],46- '1234567890',47- '3 edits away is similar for long string',48- ],49- ['123456', ['1234567890'], null, '4 edits is too far'],50- ['xat', ['rat', 'cat', 'bat'], 'bat, cat, rat', 'sorted possibles'],51- [52- 'cart',53- ['camb', 'cant', 'bard'],54- 'cant',55- 'only closest of different edit distances',56- ],57-])(58- 'when cli of %s and commands %j then suggest %s because %s',59- (arg, commandNames, expected) => {60- const program = new Command();61- commandNames.forEach((name) => {62- program.command(name);63- });64- const suggestion = getSuggestion(program, arg);65- expect(suggestion).toBe(expected);66- },67-);35+ const commandSuggestionTable = [36+ ['yyy', ['zzz'], null, 'none similar'],37+ ['a', ['b'], null, 'one edit away but not similar'],38+ ['a', ['ab'], 'ab', 'one edit away'],39+ ['ab', ['a'], null, 'one edit away'],40+ ['at', ['cat'], 'cat', '1 insertion'],41+ ['cat', ['at'], 'at', '1 deletion'],42+ ['bat', ['cat'], 'cat', '1 substitution'],43+ ['act', ['cat'], 'cat', '1 transposition'],44+ ['cxx', ['cat'], null, '2 edits away and short string'],45+ ['caxx', ['cart'], 'cart', '2 edits away and longer string'],46+ [47+ '1234567',48+ ['1234567890'],49+ '1234567890',50+ '3 edits away is similar for long string',51+ ],52+ ['123456', ['1234567890'], null, '4 edits is too far'],53+ ['xat', ['rat', 'cat', 'bat'], 'bat, cat, rat', 'sorted possibles'],54+ [55+ 'cart',56+ ['camb', 'cant', 'bard'],57+ 'cant',58+ 'only closest of different edit distances',59+ ],60+ ];61+ commandSuggestionTable.forEach(62+ ([arg, commandNames, expected, description]) => {63+ test(`when cli of ${arg} and commands ${JSON.stringify(commandNames)} then suggest ${expected} because ${description}`, () => {64+ const program = new Command();65+ commandNames.forEach((name) => {66+ program.command(name);67+ });68+ const suggestion = getSuggestion(program, arg);69+ assert.equal(suggestion, expected);70+ });71+ },72+ );73+});74 75 test('when similar alias then suggest alias', () => {76 const program = new Command();77 program.command('xyz').alias('car');78 const suggestion = getSuggestion(program, 'bar');73- expect(suggestion).toBe('car');79+ assert.equal(suggestion, 'car');80 });81 82 test('when similar hidden alias then not suggested', () => {83 const program = new Command();84 program.command('xyz').alias('visible').alias('silent');85 const suggestion = getSuggestion(program, 'slent');80- expect(suggestion).toBe(null);86+ assert.equal(suggestion, null);87 });88 89 test('when similar command and alias then suggest both', () => {90 const program = new Command();91 program.command('aaaaa').alias('cat');92 program.command('bat');93 program.command('ccccc');94 const suggestion = getSuggestion(program, 'mat');89- expect(suggestion).toBe('bat, cat');95+ assert.equal(suggestion, 'bat, cat');96 });97 98 test('when implicit help command then help is candidate for suggestion', () => {99 const program = new Command();100 program.command('sub');101 const suggestion = getSuggestion(program, 'hepl');96- expect(suggestion).toBe('help');102+ assert.equal(suggestion, 'help');103 });104 105 test('when help command disabled then not candidate for suggestion', () => {106 const program = new Command();107 program.addHelpCommand(false);108 program.command('sub');109 const suggestion = getSuggestion(program, 'hepl');104- expect(suggestion).toBe(null);110+ assert.equal(suggestion, null);111 });112 113 test('when default help option then --help is candidate for suggestion', () => {114 const program = new Command();115 const suggestion = getSuggestion(program, '--hepl');110- expect(suggestion).toBe('--help');116+ assert.equal(suggestion, '--help');117 });118 119 test('when custom help option then --custom-help is candidate for suggestion', () => {120 const program = new Command();121 program.helpOption('-H, --custom-help');122 const suggestion = getSuggestion(program, '--custom-hepl');117- expect(suggestion).toBe('--custom-help');123+ assert.equal(suggestion, '--custom-help');124 });125 126 test('when help option disabled then not candidate for suggestion', () => {127 const program = new Command();128 program.helpOption(false);129 const suggestion = getSuggestion(program, '--hepl');124- expect(suggestion).toBe(null);130+ assert.equal(suggestion, null);131 });132 133 test('when command:* listener and unknown command then no suggestion', () => {134 // Because one use for command:* was to handle unknown commands.1 unmodified line136 const program = new Command();137 program.on('command:*', () => {});138 program.command('rat');139 const suggestion = getSuggestion(program, 'cat');134- expect(suggestion).toBe(null);140+ assert.equal(suggestion, null);141 });142 137-// Easy to just run same tests as for commands with cut and paste!138-// Note: length calculations disregard the leading --139-test.each([140- ['--yyy', ['--zzz'], null, 'none similar'],141- ['--a', ['--b'], null, 'one edit away but not similar'],142- ['--a', ['--ab'], '--ab', 'one edit away'],143- ['--ab', ['--a'], null, 'one edit away'],144- ['--at', ['--cat'], '--cat', '1 insertion'],145- ['--cat', ['--at'], '--at', '1 deletion'],146- ['--bat', ['--cat'], '--cat', '1 substitution'],147- ['--act', ['--cat'], '--cat', '1 transposition'],148- ['--cxx', ['--cat'], null, '2 edits away and short string'],149- ['--caxx', ['--cart'], '--cart', '2 edits away and longer string'],150- [151- '--1234567',152- ['--1234567890'],153- '--1234567890',154- '3 edits away is similar for long string',155- ],156- ['--123456', ['--1234567890'], null, '4 edits is too far'],157- [158- '--xat',159- ['--rat', '--cat', '--bat'],160- '--bat, --cat, --rat',161- 'sorted possibles',162- ],163- [164- '--cart',165- ['--camb', '--cant', '--bard'],166- '--cant',167- 'only closest of different edit distances',168- ],169-])(143+describe('option suggestions', () => {144+ const optionSuggestionTable = [145+ ['--yyy', ['--zzz'], null, 'none similar'],146+ ['--a', ['--b'], null, 'one edit away but not similar'],147+ ['--a', ['--ab'], '--ab', 'one edit away'],148+ ['--ab', ['--a'], null, 'one edit away'],149+ ['--at', ['--cat'], '--cat', '1 insertion'],150+ ['--cat', ['--at'], '--at', '1 deletion'],151+ ['--bat', ['--cat'], '--cat', '1 substitution'],152+ ['--act', ['--cat'], '--cat', '1 transposition'],153+ ['--cxx', ['--cat'], null, '2 edits away and short string'],154+ ['--caxx', ['--cart'], '--cart', '2 edits away and longer string'],155+ [156+ '--1234567',157+ ['--1234567890'],158+ '--1234567890',159+ '3 edits away is similar for long string',160+ ],161+ ['--123456', ['--1234567890'], null, '4 edits is too far'],162+ [163+ '--xat',164+ ['--rat', '--cat', '--bat'],165+ '--bat, --cat, --rat',166+ 'sorted possibles',167+ ],168+ [169+ '--cart',170+ ['--camb', '--cant', '--bard'],171+ '--cant',172+ 'only closest of different edit distances',173+ ],174+ ];170- 'when cli of %s and options %j then suggest %s because %s',171- (arg, commandNames, expected) => {172- const program = new Command();173- commandNames.forEach((name) => {174- program.option(name);175- });176- const suggestion = getSuggestion(program, arg);177- expect(suggestion).toBe(expected);178- },179-);175 176+ optionSuggestionTable.forEach(177+ ([arg, commandNames, expected, description]) => {178+ test(`when cli of ${arg} and options ${JSON.stringify(commandNames)} then suggest ${expected} because ${description}`, () => {179+ const program = new Command();180+ commandNames.forEach((name) => {181+ program.option(name);182+ });183+ const suggestion = getSuggestion(program, arg);184+ assert.equal(suggestion, expected);185+ });186+ },187+ );188+});189+190 test('when no options then no suggestion', () => {191 // Checking nothing blows up as much as no suggestion!192 const program = new Command();193 program.helpOption(false);194 const suggestion = getSuggestion(program, '--option');186- expect(suggestion).toBe(null);195+ assert.equal(suggestion, null);196 });197 198 test('when subcommand option then candidate for subcommand option suggestion', () => {199 const program = new Command();200 program.command('sub').option('-l,--local');201 const suggestion = getSuggestion(program, ['sub', '--loca']);193- expect(suggestion).toBe('--local');202+ assert.equal(suggestion, '--local');203 });204 205 test('when global option then candidate for subcommand option suggestion', () => {206 const program = new Command();207 program.option('-g, --global');208 program.command('sub');209 const suggestion = getSuggestion(program, ['sub', '--globla']);201- expect(suggestion).toBe('--global');210+ assert.equal(suggestion, '--global');211 });212 213 test('when global option but positionalOptions then not candidate for subcommand suggestion', () => {214 const program = new Command();215 program.enablePositionalOptions();216 program.option('-g, --global');217 program.command('sub');218 const suggestion = getSuggestion(program, ['sub', '--globla']);210- expect(suggestion).toBe(null);219+ assert.equal(suggestion, null);220 });221 222 test('when global and local options then both candidates', () => {223 const program = new Command();224 program.option('--cat');225 program.command('sub').option('--rat');226 const suggestion = getSuggestion(program, ['sub', '--bat']);218- expect(suggestion).toBe('--cat, --rat');227+ assert.equal(suggestion, '--cat, --rat');228 });229 230 test('when command hidden then not suggested as candidate', () => {231 const program = new Command();232 program.command('secret', { hidden: true });233 const suggestion = getSuggestion(program, 'secrt');225- expect(suggestion).toBe(null);234+ assert.equal(suggestion, null);235 });236 237 test('when option hidden then not suggested as candidate', () => {238 const program = new Command();239 program.addOption(new Option('--secret').hideHelp());240 const suggestion = getSuggestion(program, '--secrt');232- expect(suggestion).toBe(null);241+ assert.equal(suggestion, null);242 });243 244 test('when may be duplicate identical candidates then only return one', () => {245 const program = new Command();246 program.command('sub');247 const suggestion = getSuggestion(program, ['sub', '--hepl']);239- expect(suggestion).toBe('--help');248+ assert.equal(suggestion, '--help');249 });modified:tests/help.visibleArguments.test.js+18 added-12 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).1 unmodified line8 describe('visibleArguments', () => {9 test('when no arguments then empty array', () => {10 const program = new commander.Command();11 const helper = new commander.Help();10- expect(helper.visibleArguments(program)).toEqual([]);12+ assert.deepEqual(helper.visibleArguments(program), []);13 });14 15 test('when argument but no argument description then empty array', () => {16 const program = new commander.Command();17 program.argument('<file>');18 const helper = new commander.Help();17- expect(helper.visibleArguments(program)).toEqual([]);19+ assert.deepEqual(helper.visibleArguments(program), []);20 });21 22 test('when argument and argument description then returned', () => {23 const program = new commander.Command();24 program.argument('<file>', 'file description');25 const helper = new commander.Help();26 const visibleArguments = helper.visibleArguments(program);25- expect(visibleArguments.length).toEqual(1);26- expect(visibleArguments[0]).toEqual(27+ assert.equal(visibleArguments.length, 1);28+ assert.deepEqual(29+ visibleArguments[0],30 new commander.Argument('<file>', 'file description'),31 );32 });33 4 unmodified lines38 file: 'file description',39 });40 const helper = new commander.Help();41 const visibleArguments = helper.visibleArguments(program);39- expect(visibleArguments.length).toEqual(1);40- expect(visibleArguments[0]).toEqual(42+ assert.equal(visibleArguments.length, 1);43+ assert.deepEqual(44+ visibleArguments[0],45 new commander.Argument('<file>', 'file description'),46 );47 });48 2 unmodified lines51 program.argument('<file1>', 'file1 description');52 program.argument('<file2>');53 const helper = new commander.Help();54 const visibleArguments = helper.visibleArguments(program);51- expect(visibleArguments.length).toEqual(2);52- expect(visibleArguments[0]).toEqual(55+ assert.equal(visibleArguments.length, 2);56+ assert.deepEqual(57+ visibleArguments[0],58 new commander.Argument('<file1>', 'file1 description'),59 );55- expect(visibleArguments[1]).toEqual(new commander.Argument('<file2>'));60+ assert.deepEqual(visibleArguments[1], new commander.Argument('<file2>'));61 });62 63 test('when arguments and some legacy described then all returned', () => {64 const program = new commander.Command();3 unmodified lines68 file1: 'file1 description',69 });70 const helper = new commander.Help();71 const visibleArguments = helper.visibleArguments(program);67- expect(visibleArguments.length).toEqual(2);68- expect(visibleArguments[0]).toEqual(72+ assert.equal(visibleArguments.length, 2);73+ assert.deepEqual(74+ visibleArguments[0],75 new commander.Argument('<file1>', 'file1 description'),76 );71- expect(visibleArguments[1]).toEqual(new commander.Argument('<file2>'));77+ assert.deepEqual(visibleArguments[1], new commander.Argument('<file2>'));78 });79 });modified:tests/help.visibleCommands.test.js+5 added-3 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).1 unmodified line8 describe('visibleCommands', () => {9 test('when no subcommands then empty array', () => {10 const program = new commander.Command();11 const helper = new commander.Help();10- expect(helper.visibleCommands(program)).toEqual([]);12+ assert.deepEqual(helper.visibleCommands(program), []);13 });14 15 test('when add command then visible (with help)', () => {16 const program = new commander.Command();1 unmodified line18 const helper = new commander.Help();19 const visibleCommandNames = helper20 .visibleCommands(program)21 .map((cmd) => cmd.name());20- expect(visibleCommandNames).toEqual(['sub', 'help']);22+ assert.deepEqual(visibleCommandNames, ['sub', 'help']);23 });24 25 test('when commands hidden then not visible', () => {26 const program = new commander.Command();4 unmodified lines31 const helper = new commander.Help();32 const visibleCommandNames = helper33 .visibleCommands(program)34 .map((cmd) => cmd.name());33- expect(visibleCommandNames).toEqual(['visible', 'help']);35+ assert.deepEqual(visibleCommandNames, ['visible', 'help']);36 });37 });modified:tests/help.visibleGlobalOptions.test.js+6 added-4 removed
1+const { test } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 5 test('when default configuration then return empty array', () => {6 const program = new commander.Command();7 program.option('--global');8 const sub = program.command('sub');9 const helper = sub.createHelp();8- expect(helper.visibleGlobalOptions(program)).toEqual([]);10+ assert.deepEqual(helper.visibleGlobalOptions(program), []);11 });12 13 test('when showGlobalOptions:true then return program options', () => {14 const program = new commander.Command();2 unmodified lines17 const helper = sub.createHelp();18 const visibleOptionNames = helper19 .visibleGlobalOptions(sub)20 .map((option) => option.name());19- expect(visibleOptionNames).toEqual(['global']);21+ assert.deepEqual(visibleOptionNames, ['global']);22 });23 24 test('when showGlobalOptions:true and program has version then return version', () => {25 const program = new commander.Command();2 unmodified lines28 const helper = sub.createHelp();29 const visibleOptionNames = helper30 .visibleGlobalOptions(sub)31 .map((option) => option.name());30- expect(visibleOptionNames).toEqual(['version']);32+ assert.deepEqual(visibleOptionNames, ['version']);33 });34 35 test('when showGlobalOptions:true and nested commands then return combined global options', () => {36 const program = new commander.Command();3 unmodified lines40 const helper = sub2.createHelp();41 const visibleOptionNames = helper42 .visibleGlobalOptions(sub2)43 .map((option) => option.name());42- expect(visibleOptionNames).toEqual(['sub1', 'global']);44+ assert.deepEqual(visibleOptionNames, ['sub1', 'global']);45 });modified:tests/help.visibleOptions.test.js+10 added-8 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const commander = require('../');4 5 // These are tests of the Help class, not of the Command help.6 // There is some overlap with the higher level Command tests (which predate Help).4 unmodified lines11 const helper = new commander.Help();12 const visibleOptionNames = helper13 .visibleOptions(program)14 .map((option) => option.name());13- expect(visibleOptionNames).toEqual(['help']);15+ assert.deepEqual(visibleOptionNames, ['help']);16 });17 18 test('when no options and no help option then empty array', () => {19 const program = new commander.Command();20 program.helpOption(false);21 const helper = new commander.Help();20- expect(helper.visibleOptions(program)).toEqual([]);22+ assert.deepEqual(helper.visibleOptions(program), []);23 });24 25 test('when add option then visible (with help)', () => {26 const program = new commander.Command();1 unmodified line28 const helper = new commander.Help();29 const visibleOptionNames = helper30 .visibleOptions(program)31 .map((option) => option.name());30- expect(visibleOptionNames).toEqual(['visible', 'help']);32+ assert.deepEqual(visibleOptionNames, ['visible', 'help']);33 });34 35 test('when option hidden then not visible', () => {36 const program = new commander.Command();3 unmodified lines40 const helper = new commander.Help();41 const visibleOptionNames = helper42 .visibleOptions(program)43 .map((option) => option.name());42- expect(visibleOptionNames).toEqual(['visible', 'help']);44+ assert.deepEqual(visibleOptionNames, ['visible', 'help']);45 });46 });47 48 describe('implicit help', () => {49 test('when default then help term is -h, --help', () => {50 const program = new commander.Command();51 const helper = new commander.Help();52 const implicitHelp = helper.visibleOptions(program)[0];51- expect(helper.optionTerm(implicitHelp)).toEqual('-h, --help');53+ assert.equal(helper.optionTerm(implicitHelp), '-h, --help');54 });55 56 test('when short flag obscured then help term is --help', () => {57 const program = new commander.Command();58 program.addOption(new commander.Option('-h, --huge').hideHelp());59 const helper = new commander.Help();60 const implicitHelp = helper.visibleOptions(program)[0];59- expect(helper.optionTerm(implicitHelp)).toEqual('--help');61+ assert.equal(helper.optionTerm(implicitHelp), '--help');62 });63 64 test('when long flag obscured then help term is --h', () => {65 const program = new commander.Command();66 program.addOption(new commander.Option('-H, --help').hideHelp());67 const helper = new commander.Help();68 const implicitHelp = helper.visibleOptions(program)[0];67- expect(helper.optionTerm(implicitHelp)).toEqual('-h');69+ assert.equal(helper.optionTerm(implicitHelp), '-h');70 });71 72 test('when help flags obscured then implicit help hidden', () => {73 const program = new commander.Command();74 program.addOption(new commander.Option('-h, --help').hideHelp());75 const helper = new commander.Help();74- expect(helper.visibleOptions(program)).toEqual([]);76+ assert.deepEqual(helper.visibleOptions(program), []);77 });78 });modified:tests/helpGroup.test.js+34 added-31 removed
1+const { test, describe } = require('node:test');2+const assert = require('node:assert/strict');3 const { Command, Option } = require('../');4 5 // Similar tests for Option.helpGroup() and Command.helpGroup(),6 // and for Command.optionsGroup() and Command.commandsGroup().2 unmodified lines9 test('when add one option with helpGroup then help contains group', () => {10 const program = new Command();11 program.addOption(new Option('--alpha').helpGroup('Greek:'));12 const helpInfo = program.helpInformation();11- expect(helpInfo).toMatch(/Greek:\n *--alpha/);13+ assert.match(helpInfo, /Greek:\n *--alpha/);14 });15 16 test('when add two options with helpGroup then help contains group', () => {17 const program = new Command();18 program.addOption(new Option('--alpha').helpGroup('Greek:'));19 program.addOption(new Option('--beta').helpGroup('Greek:'));20 const helpInfo = program.helpInformation();19- expect(helpInfo).toMatch(/Greek:\n *--alpha\n *--beta/);21+ assert.match(helpInfo, /Greek:\n *--alpha\n *--beta/);22 });23 });24 25 describe('Command.helpGroup', () => {26 test('when add one command with helpGroup then help contains group', () => {27 const program = new Command();28 program.command('alpha').helpGroup('Greek:');29 const helpInfo = program.helpInformation();28- expect(helpInfo).toMatch(/Greek:\n *alpha/);30+ assert.match(helpInfo, /Greek:\n *alpha/);31 });32 33 test('when add two commands with helpGroup then help contains group', () => {34 const program = new Command();35 program.command('alpha').helpGroup('Greek:');36 program.command('beta').helpGroup('Greek:');37 const helpInfo = program.helpInformation();36- expect(helpInfo).toMatch(/Greek:\n *alpha\n *beta/);38+ assert.match(helpInfo, /Greek:\n *alpha\n *beta/);39 });40 });41 42 describe('.optionsGroup', () => {1 unmodified line44 const program = new Command();45 program.optionsGroup('Greek:');46 program.option('--alpha');47 const helpInfo = program.helpInformation();46- expect(helpInfo).toMatch(/Greek:\n *--alpha/);48+ assert.match(helpInfo, /Greek:\n *--alpha/);49 });50 51 test('when add two options then help contains group with two options', () => {52 const program = new Command();53 program.optionsGroup('Greek:');54 program.option('--alpha');55 program.option('--beta');56 const helpInfo = program.helpInformation();55- expect(helpInfo).toMatch(/Greek:\n *--alpha\n *--beta/);57+ assert.match(helpInfo, /Greek:\n *--alpha\n *--beta/);58 });59 60 test('when add options with different groups then help contains two groups', () => {61 const program = new Command();1 unmodified line63 program.option('--alpha');64 program.optionsGroup('Latin:');65 program.option('--unus');66 const helpInfo = program.helpInformation();65- expect(helpInfo).toMatch(/Greek:\n *--alpha/);66- expect(helpInfo).toMatch(/Latin:\n *--unus/);67+ assert.match(helpInfo, /Greek:\n *--alpha/);68+ assert.match(helpInfo, /Latin:\n *--unus/);69 });70 71 test('when implicit help option then help option not affected', () => {72 const program = new Command();73 program.optionsGroup('Greek:');74 program.option('--alpha');75 const helpInfo = program.helpInformation();74- expect(helpInfo).toMatch(/Options:\n *-h, --help/);76+ assert.match(helpInfo, /Options:\n *-h, --help/);77 });78 79 test('when option with helpGroup then helpGroup wins', () => {80 const program = new Command();81 program.optionsGroup('Greek:');82 program.addOption(new Option('--unus').helpGroup('Latin:'));83 const helpInfo = program.helpInformation();82- expect(helpInfo).toMatch(/Latin:\n *--unus/);84+ assert.match(helpInfo, /Latin:\n *--unus/);85 });86 87 test('when add no options with heading then heading does not appear', () => {88 const program = new Command();89 program.optionsGroup('Greek:');90 const helpInfo = program.helpInformation();89- expect(helpInfo).not.toMatch(/Greek/);91+ assert.doesNotMatch(helpInfo, /Greek/);92 });93 94 test('when add no visible options with heading then heading does not appear', () => {95 const program = new Command();96 program.optionsGroup('Greek:');97 program.addOption(new Option('--alpha').hideHelp());98 const helpInfo = program.helpInformation();97- expect(helpInfo).not.toMatch(/Greek/);99+ assert.doesNotMatch(helpInfo, /Greek/);100 });101 102 test('when .helpOption(flags) then help option in group', () => {103 const program = new Command();104 program.optionsGroup('Greek:');105 program.helpOption('--assist');106 const helpInfo = program.helpInformation();105- expect(helpInfo).toMatch(/Greek:\n *--assist/);107+ assert.match(helpInfo, /Greek:\n *--assist/);108 });109 110 test('when .helpOption(true) then help option in group', () => {111 const program = new Command();112 program.optionsGroup('Greek:');113 program.helpOption(true);114 const helpInfo = program.helpInformation();113- expect(helpInfo).toMatch(/Greek:\n *-h, --help/);115+ assert.match(helpInfo, /Greek:\n *-h, --help/);116 });117 118 test('when .version(str) then version option in group', () => {119 const program = new Command();120 program.optionsGroup('Greek:');121 program.version('1.2.3');122 const helpInfo = program.helpInformation();121- expect(helpInfo).toMatch(/Greek:\n *-V, --version/);123+ assert.match(helpInfo, /Greek:\n *-V, --version/);124 });125 126 test('when set sortOptions then options are sorted within groups', () => {127 const program = new Command();4 unmodified lines132 program.optionsGroup('Greek:');133 program.option('--beta');134 program.option('--alpha');135 const helpInfo = program.helpInformation();134- expect(helpInfo).toMatch(/Latin:\n *--duo\n *--unus/);135- expect(helpInfo).toMatch(/Greek:\n *--alpha\n *--beta/);136+ assert.match(helpInfo, /Latin:\n *--duo\n *--unus/);137+ assert.match(helpInfo, /Greek:\n *--alpha\n *--beta/);138 });139 140 test('when set sortOptions then groups are in order added not sorted', () => {141 const program = new Command();1 unmodified line143 program.addOption(new Option('--bbb').helpGroup('BBB:'));144 program.addOption(new Option('--ccc').helpGroup('CCC:'));145 program.addOption(new Option('--aaa').helpGroup('AAA:'));146 const helpInfo = program.helpInformation();145- expect(helpInfo).toMatch(147+ assert.match(148+ helpInfo,149 /BBB:\n *--bbb.*\n\nCCC:\n *--ccc.*\n\nAAA:\n *--aaa/,150 );151 });152 });3 unmodified lines156 const program = new Command();157 program.commandsGroup('Greek:');158 program.command('alpha');159 const helpInfo = program.helpInformation();157- expect(helpInfo).toMatch(/Greek:\n *alpha/);160+ assert.match(helpInfo, /Greek:\n *alpha/);161 });162 163 test('when add two commands then help contains group with two commands', () => {164 const program = new Command();165 program.commandsGroup('Greek:');166 program.command('alpha');167 program.command('beta');168 const helpInfo = program.helpInformation();166- expect(helpInfo).toMatch(/Greek:\n *alpha\n *beta/);169+ assert.match(helpInfo, /Greek:\n *alpha\n *beta/);170 });171 172 test('when add commands with different groups then help contains two groups', () => {173 const program = new Command();1 unmodified line175 program.command('alpha');176 program.commandsGroup('Latin:');177 program.command('unus');178 const helpInfo = program.helpInformation();176- expect(helpInfo).toMatch(/Greek:\n *alpha/);177- expect(helpInfo).toMatch(/Latin:\n *unus/);179+ assert.match(helpInfo, /Greek:\n *alpha/);180+ assert.match(helpInfo, /Latin:\n *unus/);181 });182 183 test('when implicit help command then help command not affected', () => {184 const program = new Command();185 program.commandsGroup('Greek:');186 program.command('alpha');187 const helpInfo = program.helpInformation();185- expect(helpInfo).toMatch(/Commands:\n *help/);188+ assert.match(helpInfo, /Commands:\n *help/);189 });190 191 test('when command with custom helpGroup then helpGroup wins', () => {192 const program = new Command();193 program.commandsGroup('Greek:');194 program.command('unus').helpGroup('Latin:');195 const helpInfo = program.helpInformation();193- expect(helpInfo).toMatch(/Latin:\n *unus/);196+ assert.match(helpInfo, /Latin:\n *unus/);197 });198 199 test('when add no commands with heading then heading does not appear', () => {200 const program = new Command();201 program.commandsGroup('Greek:');202 const helpInfo = program.helpInformation();200- expect(helpInfo).not.toMatch(/Greek/);203+ assert.doesNotMatch(helpInfo, /Greek/);204 });205 206 test('when add no visible command with heading then heading does not appear', () => {207 const program = new Command();208 program.commandsGroup('Greek:');209 program.command('alpha', { hidden: true });210 const helpInfo = program.helpInformation();208- expect(helpInfo).not.toMatch(/Greek/);211+ assert.doesNotMatch(helpInfo, /Greek/);212 });213 214 test('when .helpCommand(name) then help command in group', () => {215 const program = new Command();216 program.command('foo');217 program.commandsGroup('Greek:');218 program.helpCommand('assist');219 const helpInfo = program.helpInformation();217- expect(helpInfo).toMatch(/Greek:\n *assist/);220+ assert.match(helpInfo, /Greek:\n *assist/);221 });222 223 test('when .helpCommand(true) then help command in group', () => {224 const program = new Command();225 program.command('foo');226 program.commandsGroup('Greek:');227 program.helpCommand(true);228 const helpInfo = program.helpInformation();226- expect(helpInfo).toMatch(/Greek:\n *help/);229+ assert.match(helpInfo, /Greek:\n *help/);230 });231 232 test('when set sortCommands then commands are sorted within groups', () => {233 const program = new Command();4 unmodified lines238 program.commandsGroup('Greek:');239 program.command('beta');240 program.command('alpha');241 const helpInfo = program.helpInformation();239- expect(helpInfo).toMatch(/Latin:\n *duo\n *unus/);240- expect(helpInfo).toMatch(/Greek:\n *alpha\n *beta/);242+ assert.match(helpInfo, /Latin:\n *duo\n *unus/);243+ assert.match(helpInfo, /Greek:\n *alpha\n *beta/);244 });245 246 test('when set sortOptions then groups are in order added not sorted', () => {247 const program = new Command();1 unmodified line249 program.command('bbb').helpGroup('BBB:');250 program.command('ccc').helpGroup('CCC:');251 program.command('aaa').helpGroup('AAA:');252 const helpInfo = program.helpInformation();250- expect(helpInfo).toMatch(/BBB:\n *bbb.*\n\nCCC:\n *ccc.*\n\nAAA:\n *aaa/);253+ assert.match(helpInfo, /BBB:\n *bbb.*\n\nCCC:\n *ccc.*\n\nAAA:\n *aaa/);254 });255 });added:tests/imports.test.cjs+73 added
1+const {2+ program,3+ Command,4+ Option,5+ Argument,6+ Help,7+ CommanderError,8+ InvalidArgumentError,9+ InvalidOptionArgumentError,10+ createCommand,11+ createOption,12+ createArgument,13+} = require('../index.js');14+const { describe, test } = require('node:test');15+const assert = require('node:assert/strict');16+17+// Do some testing of the default export(s).18+// Same tests in imports.test.mjs.19+20+function checkClass(obj, name) {21+ assert.equal(typeof obj, 'object');22+ assert.equal(obj.constructor.name, name);23+}24+25+describe('imports from .cjs', () => {26+ test('program', () => {27+ checkClass(program, 'Command');28+ });29+30+ test('Command', () => {31+ checkClass(new Command('name'), 'Command');32+ });33+34+ test('Option', () => {35+ checkClass(new Option('-e, --example', 'description'), 'Option');36+ });37+38+ test('Argument', () => {39+ checkClass(new Argument('<foo>', 'description'), 'Argument');40+ });41+42+ test('Help', () => {43+ checkClass(new Help(), 'Help');44+ });45+46+ test('CommanderError', () => {47+ checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');48+ });49+50+ test('InvalidArgumentError', () => {51+ checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');52+ });53+54+ test('InvalidOptionArgumentError', () => {55+ // Deprecated56+ checkClass(57+ new InvalidOptionArgumentError('failed'),58+ 'InvalidArgumentError',59+ );60+ });61+62+ test('createCommand', () => {63+ checkClass(createCommand('foo'), 'Command');64+ });65+66+ test('createOption', () => {67+ checkClass(createOption('-e, --example', 'description'), 'Option');68+ });69+70+ test('createArgument', () => {71+ checkClass(createArgument('<foo>', 'description'), 'Argument');72+ });73+});added:tests/imports.test.mjs+73 added
1+import {2+ program,3+ Command,4+ Option,5+ Argument,6+ Help,7+ CommanderError,8+ InvalidArgumentError,9+ InvalidOptionArgumentError,10+ createCommand,11+ createArgument,12+ createOption,13+} from '../index.js';14+import { describe, test } from 'node:test';15+import assert from 'node:assert/strict';16+17+// Do some testing of the default export(s).18+// Same tests in imports.test.cjs.19+20+function checkClass(obj, name) {21+ assert.equal(typeof obj, 'object');22+ assert.equal(obj.constructor.name, name);23+}24+25+describe('imports from .mjs', () => {26+ test('program', () => {27+ checkClass(program, 'Command');28+ });29+30+ test('Command', () => {31+ checkClass(new Command('name'), 'Command');32+ });33+34+ test('Option', () => {35+ checkClass(new Option('-e, --example', 'description'), 'Option');36+ });37+38+ test('Argument', () => {39+ checkClass(new Argument('<foo>', 'description'), 'Argument');40+ });41+42+ test('Help', () => {43+ checkClass(new Help(), 'Help');44+ });45+46+ test('CommanderError', () => {47+ checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');48+ });49+50+ test('InvalidArgumentError', () => {51+ checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');52+ });53+54+ test('InvalidOptionArgumentError', () => {55+ // Deprecated56+ checkClass(57+ new InvalidOptionArgumentError('failed'),58+ 'InvalidArgumentError',59+ );60+ });61+62+ test('createCommand', () => {63+ checkClass(createCommand('foo'), 'Command');64+ });65+66+ test('createOption', () => {67+ checkClass(createOption('-e, --example', 'description'), 'Option');68+ });69+70+ test('createArgument', () => {71+ checkClass(createArgument('<foo>', 'description'), 'Argument');72+ });73+});modified:tests/incrementNodeInspectorPort.test.js+47 added-40 removed
1+const { test, describe, after } = require('node:test');2+const assert = require('node:assert/strict');3 const childProcess = require('child_process');4 const path = require('path');5 const commander = require('../');6 7 describe('incrementNodeInspectorPort', () => {6- let spawnSpy;7- let signalSpy;8- const oldExecArgv = process.execArgv;9-10- beforeAll(() => {11- spawnSpy = jest.spyOn(childProcess, 'spawn').mockImplementation(() => {8+ function makeSpies(t) {9+ const spawnSpy = t.mock.method(childProcess, 'spawn', () => {10 return {11 on: () => {},12 };13 });16- signalSpy = jest.spyOn(process, 'on').mockImplementation(() => {});17- });14+ const signalSpy = test.mock.method(process, 'on', () => {});15+ return { spawnSpy, signalSpy };16+ }17 19- afterEach(() => {20- spawnSpy.mockClear();21- });18+ const oldExecArgv = process.execArgv;19 23- afterAll(() => {24- spawnSpy.mockRestore();25- signalSpy.mockRestore();20+ after(() => {21 process.execArgv = oldExecArgv;22 });23 24 function makeProgram() {4 unmodified lines29 });30 return program;31 }32 38- function extractMockExecArgs(mock) {39- return mock.mock.calls[0][1].slice(0, -1);33+ function extractMockExecArgs(spawnSpy) {34+ return spawnSpy.mock.calls[0].arguments[1].slice(0, -1);35 }36 42- test('when --inspect then bump port', () => {37+ test('when --inspect then bump port', (t) => {38+ const { spawnSpy } = makeSpies(t);39 const program = makeProgram();40 process.execArgv = ['--inspect'];41 program.parse(['node', 'test', 'cache']);42 const execArgs = extractMockExecArgs(spawnSpy);47- expect(execArgs).toEqual(['--inspect=127.0.0.1:9230']);43+ assert.deepEqual(execArgs, ['--inspect=127.0.0.1:9230']);44 });45 50- test('when --inspect=100 then bump port', () => {46+ test('when --inspect=100 then bump port', (t) => {47+ const { spawnSpy } = makeSpies(t);48 const program = makeProgram();49 process.execArgv = ['--inspect=100'];50 program.parse(['node', 'test', 'cache']);51 const execArgs = extractMockExecArgs(spawnSpy);55- expect(execArgs).toEqual(['--inspect=127.0.0.1:101']);52+ assert.deepEqual(execArgs, ['--inspect=127.0.0.1:101']);53 });54 58- test('when --inspect=1.2.3.4:100 then bump port', () => {55+ test('when --inspect=1.2.3.4:100 then bump port', (t) => {56+ const { spawnSpy } = makeSpies(t);57 const program = makeProgram();58 process.execArgv = ['--inspect=1.2.3.4:100'];59 program.parse(['node', 'test', 'cache']);60 const execArgs = extractMockExecArgs(spawnSpy);63- expect(execArgs).toEqual(['--inspect=1.2.3.4:101']);61+ assert.deepEqual(execArgs, ['--inspect=1.2.3.4:101']);62 });63 66- test('when --inspect=1.2.3.4 then bump port', () => {64+ test('when --inspect=1.2.3.4 then bump port', (t) => {65+ const { spawnSpy } = makeSpies(t);66 const program = makeProgram();67 process.execArgv = ['--inspect=1.2.3.4'];68 program.parse(['node', 'test', 'cache']);69 const execArgs = extractMockExecArgs(spawnSpy);71- expect(execArgs).toEqual(['--inspect=1.2.3.4:9230']);70+ assert.deepEqual(execArgs, ['--inspect=1.2.3.4:9230']);71 });72 74- test('when --inspect-brk then bump port', () => {73+ test('when --inspect-brk then bump port', (t) => {74+ const { spawnSpy } = makeSpies(t);75 const program = makeProgram();76 process.execArgv = ['--inspect-brk'];77 program.parse(['node', 'test', 'cache']);78 const execArgs = extractMockExecArgs(spawnSpy);79- expect(execArgs).toEqual(['--inspect-brk=127.0.0.1:9230']);79+ assert.deepEqual(execArgs, ['--inspect-brk=127.0.0.1:9230']);80 });81 82- test('when --inspect-brk=100 then bump port', () => {82+ test('when --inspect-brk=100 then bump port', (t) => {83+ const { spawnSpy } = makeSpies(t);84 const program = makeProgram();85 process.execArgv = ['--inspect-brk=100'];86 program.parse(['node', 'test', 'cache']);87 const execArgs = extractMockExecArgs(spawnSpy);87- expect(execArgs).toEqual(['--inspect-brk=127.0.0.1:101']);88+ assert.deepEqual(execArgs, ['--inspect-brk=127.0.0.1:101']);89 });90 90- test('when --inspect-brk=1.2.3.4 then bump port', () => {91+ test('when --inspect-brk=1.2.3.4 then bump port', (t) => {92+ const { spawnSpy } = makeSpies(t);93 const program = makeProgram();94 process.execArgv = ['--inspect-brk=1.2.3.4'];95 program.parse(['node', 'test', 'cache']);96 const execArgs = extractMockExecArgs(spawnSpy);95- expect(execArgs).toEqual(['--inspect-brk=1.2.3.4:9230']);97+ assert.deepEqual(execArgs, ['--inspect-brk=1.2.3.4:9230']);98 });99 98- test('when --inspect-brk=1.2.3.4:100 then bump port', () => {100+ test('when --inspect-brk=1.2.3.4:100 then bump port', (t) => {101+ const { spawnSpy } = makeSpies(t);102 const program = makeProgram();103 process.execArgv = ['--inspect-brk=1.2.3.4:100'];104 program.parse(['node', 'test', 'cache']);105 const execArgs = extractMockExecArgs(spawnSpy);103- expect(execArgs).toEqual(['--inspect-brk=1.2.3.4:101']);106+ assert.deepEqual(execArgs, ['--inspect-brk=1.2.3.4:101']);107 });108 106- test('when --inspect-port=100 then bump port', () => {109+ test('when --inspect-port=100 then bump port', (t) => {110+ const { spawnSpy } = makeSpies(t);111 const program = makeProgram();112 process.execArgv = ['--inspect-port=100'];113 program.parse(['node', 'test', 'cache']);114 const execArgs = extractMockExecArgs(spawnSpy);111- expect(execArgs).toEqual(['--inspect-port=127.0.0.1:101']);115+ assert.deepEqual(execArgs, ['--inspect-port=127.0.0.1:101']);116 });117 114- test('when --inspect-port=1.2.3.4:100 then bump port', () => {118+ test('when --inspect-port=1.2.3.4:100 then bump port', (t) => {119+ const { spawnSpy } = makeSpies(t);120 const program = makeProgram();121 process.execArgv = ['--inspect-port=1.2.3.4:100'];122 program.parse(['node', 'test', 'cache']);123 const execArgs = extractMockExecArgs(spawnSpy);119- expect(execArgs).toEqual(['--inspect-port=1.2.3.4:101']);124+ assert.deepEqual(execArgs, ['--inspect-port=1.2.3.4:101']);125 });126 122- test('when --inspect-unexpected then unchanged', () => {127+ test('when --inspect-unexpected then unchanged', (t) => {128+ const { spawnSpy } = makeSpies(t);129 const program = makeProgram();130 process.execArgv = ['--inspect-unexpected'];131 program.parse(['node', 'test', 'cache']);132 const execArgs = extractMockExecArgs(spawnSpy);127- expect(execArgs).toEqual(['--inspect-unexpected']);133+ assert.deepEqual(execArgs, ['--inspect-unexpected']);134 });135 130- test('when --frozen-intrinsics then unchanged', () => {136+ test('when --frozen-intrinsics then unchanged', (t) => {137+ const { spawnSpy } = makeSpies(t);138 const program = makeProgram();139 process.execArgv = ['--frozen-intrinsics '];140 program.parse(['node', 'test', 'cache']);141 const execArgs = extractMockExecArgs(spawnSpy);135- expect(execArgs).toEqual(['--frozen-intrinsics ']);142+ assert.deepEqual(execArgs, ['--frozen-intrinsics ']);143 });144 });modified:tests/negatives.test.js+120 added-190 removed
1 const { Command } = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6+describe('negative numbers in args', () => {3-// boolean is whether is a consumable argument when negative numbers allowed4-const negativeNumbers = [5- ['-.1', true],6- ['-123', true],7- ['-123.45', true],8- ['-1e3', true],9- ['-1e+3', true],10- ['-1e-3', true],11- ['-1.2e3', true],12- ['-1.2e+3', true],13- ['-1.2e-3', true],14- ['-1e-3.0', false], // invalid number format15- ['--1 ', false], // invalid number format16- ['-0', true],17- ['1', true],18- ['-1x', false], // whole string is not a number19- ['-x-1 ', false], // whole string is not a number20- ['', true],21- ['-0x1234', false], // not a plain number22-];7+ // boolean is whether is a consumable argument when negative numbers allowed8+ const negativeNumbers = [9+ ['-.1', true],10+ ['-123', true],11+ ['-123.45', true],12+ ['-1e3', true],13+ ['-1e+3', true],14+ ['-1e-3', true],15+ ['-1.2e3', true],16+ ['-1.2e+3', true],17+ ['-1.2e-3', true],18+ ['-1e-3.0', false], // invalid number format19+ ['--1 ', false], // invalid number format20+ ['-0', true],21+ ['1', true],22+ ['-1x', false], // whole string is not a number23+ ['-x-1 ', false], // whole string is not a number24+ ['', true],25+ ['-0x1234', false], // not a plain number26+ ];27 24-test.each(negativeNumbers)(25- `when option-argument for short optional is %s then consumed=%s`,26- (value, consume) => {27- const program = new Command();28- program.exitOverride().configureOutput({ writeErr: () => {} });29- program.option('-o, --optional [value]', 'optional option');30- const args = ['-o', value];31- let thrown = '';32- try {33- program.parse(args, { from: 'user' });34- } catch (err) {35- thrown = err.code;28+ negativeNumbers.forEach(([value, consume]) => {29+ function callProgram(program, args, consume) {30+ if (consume) {31+ assert.doesNotThrow(() => {32+ program.parse(args, { from: 'user' });33+ });34+ } else {35+ assert.throws(36+ () => {37+ program.parse(args, { from: 'user' });38+ },39+ { code: 'commander.unknownOption' },40+ );41+ }42 }43+ test(`when option-argument for short optional is ${value} then consumed=${consume}`, () => {44+ const program = createTestCommand();45+ program.option('-o, --optional [value]', 'optional option');46+ const args = ['-o', value];47+ callProgram(program, args, consume);48+ // throws after setting optional to true49+ assert.equal(program.opts()['optional'], consume ? value : true);50+ });51 38- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');39- // throws after setting optional to true40- expect(program.opts()['optional']).toBe(consume ? value : true);41- },42-);52+ test(`when option-argument for long optional is ${value} then consumed=${consume}`, () => {53+ const program = createTestCommand();54+ program.option('-o, --optional [value]', 'optional option');55+ const args = ['--optional', value];56+ callProgram(program, args, consume);57+ // throws after setting optional to true58+ assert.equal(program.opts()['optional'], consume ? value : true);59+ });60 44-test.each(negativeNumbers)(45- `when option-argument for long optional is %s then consumed=%s`,46- (value, consume) => {47- const program = new Command();48- program.exitOverride().configureOutput({ writeErr: () => {} });49- program.option('-o, --optional [value]', 'optional option');50- const args = ['--optional', value];51- let thrown = '';52- try {53- program.parse(args, { from: 'user' });54- } catch (err) {55- thrown = err.code;56- }61+ test(`when option-argument for short optional... is ${value} then consumed=${consume}`, () => {62+ const program = createTestCommand();63+ program.option('-o, --optional [value...]', 'optional option');64+ const args = ['-o', 'first', value];65+ callProgram(program, args, consume);66+ // throws after consuming 'first'67+ assert.deepEqual(68+ program.opts()['optional'],69+ consume ? ['first', value] : ['first'],70+ );71+ });72 58- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');59- // throws after setting optional to true60- expect(program.opts()['optional']).toBe(consume ? value : true);61- },62-);73+ test(`when option-argument for long optional... is ${value} then consumed=${consume}`, () => {74+ const program = createTestCommand();75+ program.option('-o, --optional [value...]', 'optional option');76+ const args = ['--optional', 'first', value];77+ callProgram(program, args, consume);78+ // throws after consuming 'first'79+ assert.deepEqual(80+ program.opts()['optional'],81+ consume ? ['first', value] : ['first'],82+ );83+ });84 64-test.each(negativeNumbers)(65- `when option-argument for short optional... is %s then consumed=%s`,66- (value, consume) => {67- const program = new Command();68- program69- .exitOverride()70- .configureOutput({ writeErr: () => {} })71- .option('-o, --optional [value...]', 'optional option');72- const args = ['-o', 'first', value];73- let thrown = '';74- try {75- program.parse(args, { from: 'user' });76- } catch (err) {77- thrown = err.code;78- }85+ test(`when command-argument is ${value} then consumed=${consume}`, () => {86+ const program = createTestCommand();87+ program.argument('<value>', 'argument');88+ const args = [value];89+ callProgram(program, args, consume);90+ assert.deepEqual(91+ consume ? program.args : undefined,92+ consume ? [value] : undefined,93+ );94+ });95 80- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');81- // throws after consuming 'first'82- expect(program.opts()['optional']).toEqual(83- consume ? ['first', value] : ['first'],84- );85- },86-);96+ test(`when digit option defined and option-argument is %s then negative not consumed`, () => {97+ const program = createTestCommand();98+ program99+ .option('-o, --optional [value]', 'optional option')100+ .option('-9', 'register option using digit');101+ const args = ['-o', value];102+ let customConsume = value[0] !== '-';103+ callProgram(program, args, customConsume);104+ assert.equal(program.opts()['optional'], customConsume ? value : true);105+ });106 88-test.each(negativeNumbers)(89- `when option-argument for long optional... is %s then consumed=%s`,90- (value, consume) => {91- const program = new Command();92- program93- .exitOverride()94- .configureOutput({ writeErr: () => {} })95- .option('-o, --optional [value...]', 'optional option');96- const args = ['--optional', 'first', value];97- let thrown = '';98- try {99- program.parse(args, { from: 'user' });100- } catch (err) {101- thrown = err.code;102- }107+ test(`when digit option defined and command-argument is %s then negative not consumed`, () => {108+ const program = createTestCommand();109+ program.argument('[value]').option('-9', 'register option using digit');110+ const args = [value];111+ let customConsume = value[0] !== '-';112+ callProgram(program, args, customConsume);113+ assert.deepEqual(114+ customConsume ? program.args : undefined,115+ customConsume ? [value] : undefined,116+ );117+ });118+ });119+});120 104- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');105- // throws after consuming 'first'106- expect(program.opts()['optional']).toEqual(107- consume ? ['first', value] : ['first'],108- );109- },110-);111-112-test.each(negativeNumbers)(113- `when command-argument is %s then consumed=%s`,114- (value, consume) => {115- const program = new Command();116- program117- .exitOverride()118- .configureOutput({ writeErr: () => {} })119- .argument('<value>', 'argument');120- const args = [value];121- let thrown = '';122- try {123- program.parse(args, { from: 'user' });124- } catch (err) {125- thrown = err.code;126- }127-128- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');129- expect(consume ? program.args : undefined).toEqual(130- consume ? [value] : undefined,131- );132- },133-);134-135-test.each(negativeNumbers)(136- `when digit option defined and option-argument is %s then negative not consumed`,137- (value, _ignore) => {138- const program = new Command();139- program140- .exitOverride()141- .configureOutput({ writeErr: () => {} })142- .option('-o, --optional [value]', 'optional option')143- .option('-9', 'register option using digit');144- const args = ['-o', value];145- let thrown = '';146- try {147- program.parse(args, { from: 'user' });148- } catch (err) {149- thrown = err.code;150- }151-152- let consume = value[0] !== '-';153- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');154- expect(program.opts()['optional']).toBe(consume ? value : true);155- },156-);157-158-test.each(negativeNumbers)(159- `when digit option defined and command-argument is %s then negative not consumed`,160- (value, _ignore) => {161- const program = new Command();162- program163- .exitOverride()164- .configureOutput({ writeErr: () => {} })165- .argument('[value]')166- .option('-9', 'register option using digit');167- const args = [value];168- let thrown = '';169- try {170- program.parse(args, { from: 'user' });171- } catch (err) {172- thrown = err.code;173- }174-175- let consume = value[0] !== '-';176- expect(thrown).toEqual(consume ? '' : 'commander.unknownOption');177- expect(consume ? program.args : undefined).toEqual(178- consume ? [value] : undefined,179- );180- },181-);182-121 test('when complex example with negative numbers then all consumed', () => {122 const program = new Command();123 program124 .option('-o [value]', 'optional')15 unmodified lines140 '-30',141 '-11',142 ];143 program.parse(args, { from: 'user' });206- expect(program.opts()).toEqual({144+ assert.deepEqual(program.opts(), {145 o: '-20',146 m: '-30',147 O: ['-40', '-41'],148 M: ['-50', '-51'],149 });212- expect(program.args).toEqual(['-10', '-11']);150+ assert.deepEqual(program.args, ['-10', '-11']);151 });152 153 test('when program has digit option then negatives not allowed in leaf command', () => {216- const program = new Command();217- program218- .exitOverride()219- .configureOutput({ writeErr: () => {} })220- .option('-2', 'double option');154+ const program = createTestCommand();155+ program.option('-2', 'double option');156 let leafArgs;157 program158 .command('leaf')159 .argument('[value...]')160 .action((args) => {161 leafArgs = args;162 });163 const args = ['leaf', '-1'];229- expect(() => program.parse(args, { from: 'user' })).toThrow();164+ assert.throws(() => program.parse(args, { from: 'user' }));165 });166 167 test('when default command without digit option then negatives accepted', () => {168 const program = new Command();4 unmodified lines173 .action((args) => {174 leafArgs = args;175 });176 program.parse(['-1'], { from: 'user' });242- expect(leafArgs).toEqual(['-1']);177+ assert.deepEqual(leafArgs, ['-1']);178 });179 180 test('when default command with digit option then negative throws', () => {246- const program = new Command();247- program.exitOverride().configureOutput({ writeErr: () => {} });181+ const program = createTestCommand();182 program183 .command('leaf', { isDefault: true })184 .option('-2')185 .argument('[value...]')186 .action(() => {});253- expect(() => program.parse(['-1'], { from: 'user' })).toThrow();187+ assert.throws(() => program.parse(['-1'], { from: 'user' }));188 });189 190 test('when program has subcommand and action handler then negative command-argument unsupported', () => {191 // Known limitation in parsing. Only allowed negative command-arguments in leaf commands192 // to minimise changes to parsing when added support for negative numbers.259- const program = new Command();260- program261- .exitOverride()262- .configureOutput({ writeErr: () => {} })263- .argument('[value...]')264- .action(() => {});193+ const program = createTestCommand();194+ program.argument('[value...]').action(() => {});195 program.command('leaf').action(() => {});266- expect(() => program.parse(['-1'], { from: 'user' })).toThrow();196+ assert.throws(() => program.parse(['-1'], { from: 'user' }));197 });modified:tests/option.bad-flags.test.js+44 added-29 removed
1 const { Option } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Check that unsupported flags throw.4-test.each([5- { flags: '-a, -b' }, // too many short flags6- { flags: '-a, -b <value>' },7- { flags: '-a, -b, --long' },8- { flags: '--one, --two, --three' }, // too many long flags9- { flags: '-ws' }, // short flag with more than one character10- { flags: '---triple' }, // double dash not followed by a non-dash11- { flags: 'sdkjhskjh' }, // oops, no flags12- { flags: '-a,-b' }, // try all the separators13- { flags: '-a|-b' },14- { flags: '-a -b' },15-])('when construct Option with flags %p then throw', ({ flags }) => {16- expect(() => {17- new Option(flags);18- }).toThrow(/^option creation failed/);6+describe('when construct Option with unsupported flags then throw', () => {7+ const flagsList = [8+ { flags: '-a, -b' }, // too many short flags9+ { flags: '-a, -b <value>' },10+ { flags: '-a, -b, --long' },11+ { flags: '--one, --two, --three' }, // too many long flags12+ { flags: '-ws' }, // short flag with more than one character13+ { flags: '---triple' }, // double dash not followed by a non-dash14+ { flags: 'sdkjhskjh' }, // oops, no flags15+ { flags: '-a,-b' }, // try all the separators16+ { flags: '-a|-b' },17+ { flags: '-a -b' },18+ ];19+ for (const { flags } of flagsList) {20+ test(`when construct Option with flags ${flags} then throw`, () => {21+ assert.throws(22+ () => {23+ new Option(flags);24+ },25+ { message: /^option creation failed/ },26+ );27+ });28+ }29 });30 31 // Check that supported flags do not throw.22-test.each([23- { flags: '-s' }, // single short24- { flags: '--long' }, // single long25- { flags: '-b, --both' }, // short and long26- { flags: '--both, -b' }, // long and short27- { flags: '--ws, --workspace' }, // two long (morally shortish and long)28- { flags: '-b,--both <comma>' },29- { flags: '-b|--both <bar>' },30- { flags: '-b --both [space]' },31- { flags: '-v, --variadic <files...>' },32-])('when construct Option with flags %p then do not throw', ({ flags }) => {33- expect(() => {34- new Option(flags);35- }).not.toThrow();32+describe('when construct Option with supported flags then do not throw', () => {33+ const flagsList = [34+ { flags: '-s' }, // single short35+ { flags: '--long' }, // single long36+ { flags: '-b, --both' }, // short and long37+ { flags: '--both, -b' }, // long and short38+ { flags: '--ws, --workspace' }, // two long (morally shortish and long)39+ { flags: '-b,--both <comma>' },40+ { flags: '-b|--both <bar>' },41+ { flags: '-b --both [space]' },42+ { flags: '-v, --variadic <files...>' },43+ ];44+ for (const { flags } of flagsList) {45+ test(`when construct Option with flags ${flags} then do not throw`, () => {46+ assert.doesNotThrow(() => {47+ new Option(flags);48+ });49+ });50+ }51 });modified:tests/option.chain.test.js+10 added-8 removed
1 const { Option } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('Option methods that should return this for chaining', () => {6 test('when call .default() then returns this', () => {7 const option = new Option('-e,--example <value>');8 const result = option.default(3);7- expect(result).toBe(option);9+ assert.equal(result, option);10 });11 12 test('when call .argParser() then returns this', () => {13 const option = new Option('-e,--example <value>');14 const result = option.argParser(() => {});13- expect(result).toBe(option);15+ assert.equal(result, option);16 });17 18 test('when call .makeOptionMandatory() then returns this', () => {19 const option = new Option('-e,--example <value>');20 const result = option.makeOptionMandatory();19- expect(result).toBe(option);21+ assert.equal(result, option);22 });23 24 test('when call .hideHelp() then returns this', () => {25 const option = new Option('-e,--example <value>');26 const result = option.hideHelp();25- expect(result).toBe(option);27+ assert.equal(result, option);28 });29 30 test('when call .choices() then returns this', () => {31 const option = new Option('-e,--example <value>');32 const result = option.choices(['a']);31- expect(result).toBe(option);33+ assert.equal(result, option);34 });35 36 test('when call .env() then returns this', () => {37 const option = new Option('-e,--example <value>');38 const result = option.env('e');37- expect(result).toBe(option);39+ assert.equal(result, option);40 });41 42 test('when call .conflicts() then returns this', () => {43 const option = new Option('-e,--example <value>');44 const result = option.conflicts(['a']);43- expect(result).toBe(option);45+ assert.equal(result, option);46 });47 48 test('when call .helpGroup(heading) then returns this', () => {49 const option = new Option('-e,--example <value>');50 const result = option.helpGroup('Options:');49- expect(result).toBe(option);51+ assert.equal(result, option);52 });53 });modified:tests/options.bool.combo.test.js+23 added-21 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test combination of flag and --no-flag6 // (single flags tested in options.bool.test.js)7 9 unmodified lines17 18 test('when boolean combo not specified then value is undefined', () => {19 const program = createPepperProgram();20 program.parse(['node', 'test']);19- expect(program.opts().pepper).toBeUndefined();21+ assert.equal(program.opts().pepper, undefined);22 });23 24 test('when boolean combo positive then value is true', () => {25 const program = createPepperProgram();26 program.parse(['node', 'test', '--pepper']);25- expect(program.opts().pepper).toBe(true);27+ assert.equal(program.opts().pepper, true);28 });29 30 test('when boolean combo negative then value is false', () => {31 const program = createPepperProgram();32 program.parse(['node', 'test', '--no-pepper']);31- expect(program.opts().pepper).toBe(false);33+ assert.equal(program.opts().pepper, false);34 });35 36 test('when boolean combo last is positive then value is true', () => {37 const program = createPepperProgram();38 program.parse(['node', 'test', '--no-pepper', '--pepper']);37- expect(program.opts().pepper).toBe(true);39+ assert.equal(program.opts().pepper, true);40 });41 42 test('when boolean combo last is negative then value is false', () => {43 const program = createPepperProgram();44 program.parse(['node', 'test', '--pepper', '--no-pepper']);43- expect(program.opts().pepper).toBe(false);45+ assert.equal(program.opts().pepper, false);46 });47 });48 49 // Flag with default, say from an environment variable.10 unmodified lines60 describe('boolean option combo, default true, long flags', () => {61 test('when boolean combo not specified then value is true', () => {62 const program = createPepperProgramWithDefault(true);63 program.parse(['node', 'test']);62- expect(program.opts().pepper).toBe(true);64+ assert.equal(program.opts().pepper, true);65 });66 67 test('when boolean combo positive then value is true', () => {68 const program = createPepperProgramWithDefault(true);69 program.parse(['node', 'test', '--pepper']);68- expect(program.opts().pepper).toBe(true);70+ assert.equal(program.opts().pepper, true);71 });72 73 test('when boolean combo negative then value is false', () => {74 const program = createPepperProgramWithDefault(true);75 program.parse(['node', 'test', '--no-pepper']);74- expect(program.opts().pepper).toBe(false);76+ assert.equal(program.opts().pepper, false);77 });78 });79 80 // boolean option combo, default false, short flags81 describe('boolean option combo, default false, short flags', () => {82 test('when boolean combo not specified then value is false', () => {83 const program = createPepperProgramWithDefault(false);84 program.parse(['node', 'test']);83- expect(program.opts().pepper).toBe(false);85+ assert.equal(program.opts().pepper, false);86 });87 88 test('when boolean combo positive then value is true', () => {89 const program = createPepperProgramWithDefault(false);90 program.parse(['node', 'test', '-p']);89- expect(program.opts().pepper).toBe(true);91+ assert.equal(program.opts().pepper, true);92 });93 94 test('when boolean combo negative then value is false', () => {95 const program = createPepperProgramWithDefault(false);96 program.parse(['node', 'test', '-P']);95- expect(program.opts().pepper).toBe(false);97+ assert.equal(program.opts().pepper, false);98 });99 });100 101 // boolean option combo with non-boolean default.1 unmodified line103 describe('boolean option combo with non-boolean default', () => {104 test('when boolean combo not specified then value is default', () => {105 const program = createPepperProgramWithDefault('default');106 program.parse(['node', 'test']);105- expect(program.opts().pepper).toBe('default');107+ assert.equal(program.opts().pepper, 'default');108 });109 110 test('when boolean combo positive then value is true', () => {111 const program = createPepperProgramWithDefault('default');112 program.parse(['node', 'test', '--pepper']);111- expect(program.opts().pepper).toBe(true);113+ assert.equal(program.opts().pepper, true);114 });115 116 test('when boolean combo negative then value is false', () => {117 const program = createPepperProgramWithDefault('default');118 program.parse(['node', 'test', '--no-pepper']);117- expect(program.opts().pepper).toBe(false);119+ assert.equal(program.opts().pepper, false);120 });121 });122 123 describe('boolean option combo with non-boolean default and preset', () => {11 unmodified lines135 136 test('when boolean combo not specified then value is default', () => {137 const program = createPepperProgramWithDefaultAndPreset();138 program.parse(['node', 'test']);137- expect(program.opts().pepper).toBe('default');139+ assert.equal(program.opts().pepper, 'default');140 });141 142 test('when boolean combo positive then value is preset', () => {143 const program = createPepperProgramWithDefaultAndPreset();144 program.parse(['node', 'test', '--pepper']);143- expect(program.opts().pepper).toBe('preset');145+ assert.equal(program.opts().pepper, 'preset');146 });147 148 test('when boolean combo negative then value is false', () => {149 const program = createPepperProgramWithDefaultAndPreset();150 program.parse(['node', 'test', '--no-pepper']);149- expect(program.opts().pepper).toBe(false);151+ assert.equal(program.opts().pepper, false);152 });153 });154 155 describe('only lone negative causes implicit default of true', () => {156 test('when lone negative then default value is true', () => {157 const program = new commander.Command();158 program.option('--no-pepper', 'remove pepper');159 program.parse([], { from: 'user' });158- expect(program.opts().pepper).toBe(true);160+ assert.equal(program.opts().pepper, true);161 });162 163 test('when boolean combo and negative first then no implicit default', () => {164 // New behaviour in Commander 15, now only lone negative gets implicit default of true.1 unmodified line166 program167 .option('--no-pepper', 'remove pepper')168 .option('--pepper', 'pepper only');169 program.parse([], { from: 'user' });168- expect(program.opts().pepper).toBeUndefined();170+ assert.equal(program.opts().pepper, undefined);171 });172 173 test('when boolean combo and negative second then no implicit default', () => {174 const program = new commander.Command();175 program176 .option('--pepper', 'pepper only')177 .option('--no-pepper', 'remove pepper');178 program.parse([], { from: 'user' });177- expect(program.opts().pepper).toBeUndefined();179+ assert.equal(program.opts().pepper, undefined);180 });181 182 test('when boolean combo and negative second with explicit default then get explicit default', () => {183 // Prior to Commander 15, negative second would ignore implicit and explicit default value.3 unmodified lines187 program188 .option('--pepper', 'pepper only')189 .option('--no-pepper', 'remove pepper', 'plain');190 program.parse([], { from: 'user' });189- expect(program.opts().pepper).toBe('plain');191+ assert.equal(program.opts().pepper, 'plain');192 });193 });modified:tests/options.bool.small.combined.test.js+4 added-2 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when when multiple short flags specified then all values are true', () => {6 const program = new commander.Command();7 program1 unmodified line9 .option('-c, --cheese', 'add cheese');10 11 program.parse(['node', 'test', '-pc']);12 11- expect(program.opts().pepper).toBe(true);12- expect(program.opts().cheese).toBe(true);13+ assert.equal(program.opts().pepper, true);14+ assert.equal(program.opts().cheese, true);15 });modified:tests/options.bool.test.js+15 added-13 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test simple flag and negatable flag6 7 // boolean flag on program1 unmodified line9 test('when boolean flag not specified then value is undefined', () => {10 const program = new commander.Command();11 program.option('--pepper', 'add pepper');12 program.parse(['node', 'test']);11- expect(program.opts().pepper).toBeUndefined();13+ assert.equal(program.opts().pepper, undefined);14 });15 16 test('when boolean flag specified then value is true', () => {17 const program = new commander.Command();18 program.option('--pepper', 'add pepper');19 program.parse(['node', 'test', '--pepper']);18- expect(program.opts().pepper).toBe(true);20+ assert.equal(program.opts().pepper, true);21 });22 23 test('when negatable boolean flag not specified then value is true', () => {24 const program = new commander.Command();25 program.option('--no-cheese', 'remove cheese');26 program.parse(['node', 'test']);25- expect(program.opts().cheese).toBe(true);27+ assert.equal(program.opts().cheese, true);28 });29 30 test('when negatable boolean flag specified then value is false', () => {31 const program = new commander.Command();32 program.option('--no-cheese', 'remove cheese');33 program.parse(['node', 'test', '--no-cheese']);32- expect(program.opts().cheese).toBe(false);34+ assert.equal(program.opts().cheese, false);35 });36 });37 38 // boolean flag on command7 unmodified lines46 .action((options) => {47 subCommandOptions = options;48 });49 program.parse(['node', 'test', 'sub']);48- expect(subCommandOptions.pepper).toBeUndefined();50+ assert.equal(subCommandOptions.pepper, undefined);51 });52 53 test('when boolean flag specified then value is true', () => {54 let subCommandOptions;4 unmodified lines59 .action((options) => {60 subCommandOptions = options;61 });62 program.parse(['node', 'test', 'sub', '--pepper']);61- expect(subCommandOptions.pepper).toBe(true);63+ assert.equal(subCommandOptions.pepper, true);64 });65 66 test('when negatable boolean flag not specified then value is true', () => {67 let subCommandOptions;4 unmodified lines72 .action((options) => {73 subCommandOptions = options;74 });75 program.parse(['node', 'test', 'sub']);74- expect(subCommandOptions.cheese).toBe(true);76+ assert.equal(subCommandOptions.cheese, true);77 });78 79 test('when negatable boolean flag specified then value is false', () => {80 let subCommandOptions;4 unmodified lines85 .action((options) => {86 subCommandOptions = options;87 });88 program.parse(['node', 'test', 'sub', '--no-cheese']);87- expect(subCommandOptions.cheese).toBe(false);89+ assert.equal(subCommandOptions.cheese, false);90 });91 });92 93 // boolean flag with non-boolean default4 unmodified lines98 const flagValue = 'black';99 const program = new commander.Command();100 program.option('--olives', 'Add green olives?', flagValue);101 program.parse(['node', 'test']);100- expect(program.opts().olives).toBe(flagValue);102+ assert.equal(program.opts().olives, flagValue);103 });104 105 test('when flag specified then value is true', () => {106 const flagValue = 'black';107 const program = new commander.Command();108 program.option('-v, --olives', 'Add green olives?', flagValue);109 program.parse(['node', 'test', '--olives']);108- expect(program.opts().olives).toBe(true);110+ assert.equal(program.opts().olives, true);111 });112 113 test('when combo flag and negated then value is false', () => {114 const flagValue = 'black';1 unmodified line116 program117 .option('-v, --olives', 'Add green olives?', flagValue)118 .option('--no-olives');119 program.parse(['node', 'test', '--olives', '--no-olives']);118- expect(program.opts().olives).toBe(false);120+ assert.equal(program.opts().olives, false);121 });122 });123 124 // Regression test for #1301 with `-no-` in middle of option1 unmodified line126 test('when flag not specified then value is undefined', () => {127 const program = new commander.Command();128 program.option('--module-no-parse');129 program.parse(['node', 'test']);128- expect(program.opts().moduleNoParse).toBeUndefined();130+ assert.equal(program.opts().moduleNoParse, undefined);131 });132 133 test('when flag specified then value is true', () => {134 const program = new commander.Command();135 program.option('--module-no-parse');136 program.parse(['node', 'test', '--module-no-parse']);135- expect(program.opts().moduleNoParse).toEqual(true);137+ assert.equal(program.opts().moduleNoParse, true);138 });139 });modified:tests/options.camelcase.test.js+8 added-6 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Capitalise the letters of words after dashes, but otherwise preserve case6 7 test('when option defined with --word-word then option property is wordWord', () => {8 const program = new commander.Command();9 program.option('--my-option', 'description');10 program.parse(['node', 'test', '--my-option']);9- expect(program.opts().myOption).toBe(true);11+ assert.equal(program.opts().myOption, true);12 });13 14 test('when option defined with --word-wORD then option property is wordWORD', () => {15 const program = new commander.Command();16 program.option('--my-oPTION', 'description');17 program.parse(['node', 'test', '--my-oPTION']);16- expect(program.opts().myOPTION).toBe(true);18+ assert.equal(program.opts().myOPTION, true);19 });20 21 test('when option defined with --word-WORD then option property is wordWORD', () => {22 const program = new commander.Command();23 program.option('--my-OPTION', 'description');24 program.parse(['node', 'test', '--my-OPTION']);23- expect(program.opts().myOPTION).toBe(true);25+ assert.equal(program.opts().myOPTION, true);26 });27 28 test('when option defined with --word-word-word then option property is wordWordWord', () => {29 const program = new commander.Command();30 program.option('--my-special-option', 'description');31 program.parse(['node', 'test', '--my-special-option']);30- expect(program.opts().mySpecialOption).toBe(true);32+ assert.equal(program.opts().mySpecialOption, true);33 });34 35 test('when option defined with --word-WORD-word then option property is wordWORDWord', () => {36 const program = new commander.Command();37 program.option('--my-SPECIAL-option', 'description');38 program.parse(['node', 'test', '--my-SPECIAL-option']);37- expect(program.opts().mySPECIALOption).toBe(true);39+ assert.equal(program.opts().mySPECIALOption, true);40 });41 42 test('when option defined with --Word then option property is Word', () => {43 const program = new commander.Command();44 program.option('--Myoption', 'description');45 program.parse(['node', 'test', '--Myoption']);44- expect(program.opts().Myoption).toBe(true);46+ assert.equal(program.opts().Myoption, true);47 });modified:tests/options.choices.test.js+19 added-28 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 test('when option argument in choices then option set', () => {7 const program = new commander.Command();5- program6- .exitOverride()7- .addOption(8- new commander.Option('--colour <shade>').choices(['red', 'blue']),9- );8+ program.addOption(9+ new commander.Option('--colour <shade>').choices(['red', 'blue']),10+ );11 program.parse(['--colour', 'red'], { from: 'user' });11- expect(program.opts().colour).toBe('red');12+ assert.equal(program.opts().colour, 'red');13 });14 15 test('when option argument is not in choices then error', () => {16 // Lightweight check, more detailed testing of behaviour in command.exitOverride.test.js16- const program = new commander.Command();17- program18- .exitOverride()19- .configureOutput({20- writeErr: () => {},21- })22- .addOption(23- new commander.Option('--colour <shade>').choices(['red', 'blue']),24- );25- expect(() => {17+ const program = createTestCommand();18+ program.addOption(19+ new commander.Option('--colour <shade>').choices(['red', 'blue']),20+ );21+ assert.throws(() => {22 program.parse(['--colour', 'orange'], { from: 'user' });27- }).toThrow();23+ });24 });25 26 describe('choices parameter is treated as readonly, per TypeScript declaration', () => {27 test('when choices called then parameter does not change', () => {28 // Unlikely this could break, but check the API we are declaring in TypeScript.29 const original = ['red', 'blue', 'green'];30 const param = original.slice();31 new commander.Option('--colour <shade>').choices(param);36- expect(param).toEqual(original);32+ assert.deepEqual(param, original);33 });34 35 test('when choices called and argChoices later changed then parameter does not change', () => {36 const original = ['red', 'blue', 'green'];37 const param = original.slice();38 const option = new commander.Option('--colour <shade>').choices(param);39 option.argChoices.push('purple');44- expect(param).toEqual(original);40+ assert.deepEqual(param, original);41 });42 43 test('when choices called and parameter changed the choices does not change', () => {48- const program = new commander.Command();44+ const program = createTestCommand();45 const param = ['red', 'blue'];50- program51- .exitOverride()52- .configureOutput({53- writeErr: () => {},54- })55- .addOption(new commander.Option('--colour <shade>').choices(param));46+ program.addOption(new commander.Option('--colour <shade>').choices(param));47 param.push('orange');57- expect(() => {48+ assert.throws(() => {49 program.parse(['--colour', 'orange'], { from: 'user' });59- }).toThrow();50+ });51 });52 });modified:tests/options.conflicts.test.js+177 added-127 removed
1 const path = require('path');2 const commander = require('../');3+const { createTestCommand } = require('./testHelpers');4+const { test, describe } = require('node:test');5+const assert = require('node:assert/strict');6 7 describe('command with conflicting options', () => {5- function makeProgram() {6- const actionMock = jest.fn();7- const program = new commander.Command();8+ function makeProgram(t) {9+ const actionMock = t.mock.fn();10+ const program = createTestCommand();11 program9- .exitOverride()10- .configureOutput({11- writeErr: () => {},12- writeOut: () => {},13- })12 .command('foo')13 .addOption(14 new commander.Option('-s, --silent', "Don't print anything").env(15 'SILENT',8 unmodified lines24 25 return { program, actionMock };26 }27 30- beforeEach(() => {28+ test.beforeEach(() => {29 delete process.env.SILENT;30 delete process.env.JSON;31 delete process.env.DUAL;32 delete process.env.NO_DUAL;33 });34 37- test('should call action if there are no explicit conflicting options set', () => {38- const { program, actionMock } = makeProgram();35+ test('should call action if there are no explicit conflicting options set', (t) => {36+ const { program, actionMock } = makeProgram(t);37 program.parse('node test.js foo --json'.split(' '));40- expect(actionMock).toHaveBeenCalledTimes(1);41- expect(actionMock).toHaveBeenCalledWith({ json: true }, expect.any(Object));38+ assert.equal(actionMock.mock.callCount(), 1);39+ const callArgs = actionMock.mock.calls[0].arguments;40+ assert.deepEqual(callArgs[0], { json: true });41 });42 44- test('should call action when there are no implicit conflicting options set', () => {45- const { program, actionMock } = makeProgram();43+ test('should call action when there are no implicit conflicting options set', (t) => {44+ const { program, actionMock } = makeProgram(t);45 program.parse('node test.js foo --silent'.split(' '));47- expect(actionMock).toHaveBeenCalledTimes(1);48- expect(actionMock).toHaveBeenCalledWith(49- { silent: true },50- expect.any(Object),51- );46+ assert.equal(actionMock.mock.callCount(), 1);47+ const callArgs = actionMock.mock.calls[0].arguments;48+ assert.deepEqual(callArgs[0], { silent: true });49 });50 54- test('should exit with error if conflicting options were set', () => {55- const { program } = makeProgram();51+ test('should exit with error if conflicting options were set', (t) => {52+ const { program } = makeProgram(t);53 57- expect(() => {58- program.parse('node test.js foo --silent --json'.split(' '));59- }).toThrow(60- "error: option '-j, --json' cannot be used with option '-s, --silent'",54+ assert.throws(55+ () => {56+ program.parse('node test.js foo --silent --json'.split(' '));57+ },58+ {59+ message:60+ "error: option '-j, --json' cannot be used with option '-s, --silent'",61+ },62 );63 });64 64- test('should report the env variable as the conflicting option source, when conflicting option is set', () => {65- const { program } = makeProgram();65+ test('should report the env variable as the conflicting option source, when conflicting option is set', (t) => {66+ const { program } = makeProgram(t);67 68 process.env.SILENT = true;69 69- expect(() => {70- program.parse('node test.js foo --json'.split(' '));71- }).toThrow(72- "error: option '-j, --json' cannot be used with environment variable 'SILENT'",70+ assert.throws(71+ () => {72+ program.parse('node test.js foo --json'.split(' '));73+ },74+ {75+ message:76+ "error: option '-j, --json' cannot be used with environment variable 'SILENT'",77+ },78 );79 });80 76- test('should report the env variable as the configured option source, when configured option is set', () => {77- const { program } = makeProgram();81+ test('should report the env variable as the configured option source, when configured option is set', (t) => {82+ const { program } = makeProgram(t);83 84 process.env.JSON = true;85 81- expect(() => {82- program.parse('node test.js foo --silent'.split(' '));83- }).toThrow(84- "error: environment variable 'JSON' cannot be used with option '-s, --silent'",86+ assert.throws(87+ () => {88+ program.parse('node test.js foo --silent'.split(' '));89+ },90+ {91+ message:92+ "error: environment variable 'JSON' cannot be used with option '-s, --silent'",93+ },94 );95 });96 88- test('should report both env variables as sources, when configured option and conflicting option are set', () => {89- const { program } = makeProgram();97+ test('should report both env variables as sources, when configured option and conflicting option are set', (t) => {98+ const { program } = makeProgram(t);99 100 process.env.SILENT = true;101 process.env.JSON = true;102 94- expect(() => {95- program.parse('node test.js foo'.split(' '));96- }).toThrow(97- "error: environment variable 'JSON' cannot be used with environment variable 'SILENT'",103+ assert.throws(104+ () => {105+ program.parse('node test.js foo'.split(' '));106+ },107+ {108+ message:109+ "error: environment variable 'JSON' cannot be used with environment variable 'SILENT'",110+ },111 );112 });113 101- test('should allow default value with a conflicting option', () => {102- const { program, actionMock } = makeProgram();114+ test('should allow default value with a conflicting option', (t) => {115+ const { program, actionMock } = makeProgram(t);116 117 program.commands[0].addOption(118 new commander.Option('-d, --debug', 'print debug logs')119 .default(true)1 unmodified line121 );122 123 program.parse('node test.js foo --silent'.split(' '));124 112- expect(actionMock).toHaveBeenCalledTimes(1);113- expect(actionMock).toHaveBeenCalledWith(114- { debug: true, silent: true },115- expect.any(Object),116- );125+ assert.equal(actionMock.mock.callCount(), 1);126+ const callArgs = actionMock.mock.calls[0].arguments;127+ assert.deepEqual(callArgs[0], { debug: true, silent: true });128 });129 119- test('should report conflict on negated option flag', () => {120- const { program } = makeProgram();130+ test('should report conflict on negated option flag', (t) => {131+ const { program } = makeProgram(t);132 133 program134 .command('bar')135 .addOption(new commander.Option('--red').conflicts(['color']))136 .addOption(new commander.Option('--color'))137 .addOption(new commander.Option('-N, --no-color'));138 128- expect(() => {129- program.parse('node test.js bar --red -N'.split(' '));130- }).toThrow(131- "error: option '--red' cannot be used with option '-N, --no-color'",139+ assert.throws(140+ () => {141+ program.parse('node test.js bar --red -N'.split(' '));142+ },143+ {144+ message:145+ "error: option '--red' cannot be used with option '-N, --no-color'",146+ },147 );148 });149 135- test('should report conflict on negated option env variable', () => {136- const { program } = makeProgram();150+ test('should report conflict on negated option env variable', (t) => {151+ const { program } = makeProgram(t);152 153 process.env.NO_COLOR = true;154 155 program1 unmodified line157 .addOption(new commander.Option('--red').conflicts(['color']))158 .addOption(new commander.Option('--color'))159 .addOption(new commander.Option('-N, --no-color').env('NO_COLOR'));160 146- expect(() => {147- program.parse('node test.js bar --red'.split(' '));148- }).toThrow(149- "error: option '--red' cannot be used with environment variable 'NO_COLOR'",161+ assert.throws(162+ () => {163+ program.parse('node test.js bar --red'.split(' '));164+ },165+ {166+ message:167+ "error: option '--red' cannot be used with environment variable 'NO_COLOR'",168+ },169 );170 });171 153- test('should report correct error for shorthand negated option', () => {154- const { program } = makeProgram();172+ test('should report correct error for shorthand negated option', (t) => {173+ const { program } = makeProgram(t);174 175 program176 .command('bar')177 .addOption(new commander.Option('--red'))178 .addOption(new commander.Option('-N, --no-color').conflicts(['red']));179 161- expect(() => {162- program.parse('node test.js bar --red -N'.split(' '));163- }).toThrow(164- "error: option '-N, --no-color' cannot be used with option '--red'",180+ assert.throws(181+ () => {182+ program.parse('node test.js bar --red -N'.split(' '));183+ },184+ {185+ message:186+ "error: option '-N, --no-color' cannot be used with option '--red'",187+ },188 );189 });190 168- test('should report correct error for positive option when negated is configured', () => {169- const { program } = makeProgram();191+ test('should report correct error for positive option when negated is configured', (t) => {192+ const { program } = makeProgram(t);193 194 program195 .command('bar')196 .addOption(new commander.Option('--red'))197 .addOption(new commander.Option('--dual').env('DUAL').conflicts(['red']))198 .addOption(new commander.Option('--no-dual').env('NO_DUAL'));199 177- expect(() => {178- program.parse('node test.js bar --red --dual'.split(' '));179- }).toThrow("error: option '--dual' cannot be used with option '--red'");200+ assert.throws(201+ () => {202+ program.parse('node test.js bar --red --dual'.split(' '));203+ },204+ { message: "error: option '--dual' cannot be used with option '--red'" },205+ );206 });207 182- test('should report correct error for negated option when positive is configured', () => {183- const { program } = makeProgram();208+ test('should report correct error for negated option when positive is configured', (t) => {209+ const { program } = makeProgram(t);210 211 program212 .command('bar')213 .addOption(new commander.Option('--red'))214 .addOption(new commander.Option('--dual').env('DUAL').conflicts(['red']))215 .addOption(new commander.Option('--no-dual').env('NO_DUAL'));216 191- expect(() => {192- program.parse('node test.js bar --red --no-dual'.split(' '));193- }).toThrow("error: option '--no-dual' cannot be used with option '--red'");217+ assert.throws(218+ () => {219+ program.parse('node test.js bar --red --no-dual'.split(' '));220+ },221+ {222+ message: "error: option '--no-dual' cannot be used with option '--red'",223+ },224+ );225 });226 196- test('should report correct error for positive env variable when negated is configured', () => {197- const { program } = makeProgram();227+ test('should report correct error for positive env variable when negated is configured', (t) => {228+ const { program } = makeProgram(t);229 230 program231 .command('bar')232 .addOption(new commander.Option('--red'))233 .addOption(new commander.Option('--dual').env('DUAL').conflicts(['red']))234 .addOption(new commander.Option('--no-dual').env('NO_DUAL'));235 236 process.env.DUAL = 'true';206- expect(() => {207- program.parse('node test.js bar --red'.split(' '));208- }).toThrow(209- "error: environment variable 'DUAL' cannot be used with option '--red'",237+ assert.throws(238+ () => {239+ program.parse('node test.js bar --red'.split(' '));240+ },241+ {242+ message:243+ "error: environment variable 'DUAL' cannot be used with option '--red'",244+ },245 );246 });247 213- test('should report correct error for negated env variable when positive is configured', () => {214- const { program } = makeProgram();248+ test('should report correct error for negated env variable when positive is configured', (t) => {249+ const { program } = makeProgram(t);250 251 program252 .command('bar')253 .addOption(new commander.Option('--red'))254 .addOption(new commander.Option('--dual').env('DUAL').conflicts(['red']))255 .addOption(new commander.Option('--no-dual').env('NO_DUAL'));256 257 process.env.NO_DUAL = 'true';223- expect(() => {224- program.parse('node test.js bar --red'.split(' '));225- }).toThrow(226- "error: environment variable 'NO_DUAL' cannot be used with option '--red'",258+ assert.throws(259+ () => {260+ program.parse('node test.js bar --red'.split(' '));261+ },262+ {263+ message:264+ "error: environment variable 'NO_DUAL' cannot be used with option '--red'",265+ },266 );267 });268 230- test('should report correct error for positive option with string value when negated is configured', () => {231- const { program } = makeProgram();269+ test('should report correct error for positive option with string value when negated is configured', (t) => {270+ const { program } = makeProgram(t);271 272 program273 .command('bar')274 .addOption(new commander.Option('--red'))275 .addOption(new commander.Option('--dual2 <str>').conflicts(['red']))276 .addOption(new commander.Option('--no-dual2').preset('BAD'));277 239- expect(() => {240- program.parse('node test.js bar --red --dual2 foo'.split(' '));241- }).toThrow(242- "error: option '--dual2 <str>' cannot be used with option '--red'",278+ assert.throws(279+ () => {280+ program.parse('node test.js bar --red --dual2 foo'.split(' '));281+ },282+ {283+ message:284+ "error: option '--dual2 <str>' cannot be used with option '--red'",285+ },286 );287 });288 246- test('should report correct error for negated option with preset when negated is configured', () => {247- const { program } = makeProgram();289+ test('should report correct error for negated option with preset when negated is configured', (t) => {290+ const { program } = makeProgram(t);291 292 program293 .command('bar')294 .addOption(new commander.Option('--red'))295 .addOption(new commander.Option('--dual2 <str>').conflicts(['red']))296 .addOption(new commander.Option('--no-dual2').preset('BAD'));297 255- expect(() => {256- program.parse('node test.js bar --red --no-dual2'.split(' '));257- }).toThrow("error: option '--no-dual2' cannot be used with option '--red'");298+ assert.throws(299+ () => {300+ program.parse('node test.js bar --red --no-dual2'.split(' '));301+ },302+ {303+ message:304+ "error: option '--no-dual2' cannot be used with option '--red'",305+ },306+ );307 });308 260- test('should not throw error when conflicts is invoked with a single string that includes another option', () => {261- const { program } = makeProgram();309+ test('should not throw error when conflicts is invoked with a single string that includes another option', (t) => {310+ const { program } = makeProgram(t);311 263- const actionMock = jest.fn();312+ const actionMock = t.mock.fn();313 314 program315 .command('bar')316 .addOption(new commander.Option('--a'))1 unmodified line318 .action(actionMock);319 320 program.parse('node test.js bar --a --b'.split(' '));321 273- expect(actionMock).toHaveBeenCalledTimes(1);274- expect(actionMock).toHaveBeenCalledWith(275- { a: true, b: true },276- expect.any(Object),277- );322+ assert.equal(actionMock.mock.callCount(), 1);323+ const callArgs = actionMock.mock.calls[0].arguments;324+ assert.deepEqual(callArgs[0], { a: true, b: true });325 });326 280- test('should throw error when conflicts is invoked with a single string that equals another option', () => {281- const { program } = makeProgram();327+ test('should throw error when conflicts is invoked with a single string that equals another option', (t) => {328+ const { program } = makeProgram(t);329 330 program331 .command('bar')332 .addOption(new commander.Option('--a'))333 .addOption(new commander.Option('--b').conflicts('a'));334 288- expect(() => {289- program.parse('node test.js bar --a --b'.split(' '));290- }).toThrow("error: option '--b' cannot be used with option '--a'");335+ assert.throws(336+ () => {337+ program.parse('node test.js bar --a --b'.split(' '));338+ },339+ { message: "error: option '--b' cannot be used with option '--a'" },340+ );341 });342 293- test('when conflict on program calling action subcommand then throw conflict', () => {294- const { program } = makeProgram();343+ test('when conflict on program calling action subcommand then throw conflict', (t) => {344+ const { program } = makeProgram(t);345 let exception;346 347 program348 .addOption(new commander.Option('--black'))3 unmodified lines352 program.parse('--white --black foo'.split(' '), { from: 'user' });353 } catch (err) {354 exception = err;355 }306- expect(exception).not.toBeUndefined();307- expect(exception.code).toBe('commander.conflictingOption');356+ assert.notEqual(exception, undefined);357+ assert.equal(exception.code, 'commander.conflictingOption');358 });359 310- test('when conflict on program calling action subcommand with help then show help', () => {311- const { program } = makeProgram();360+ test('when conflict on program calling action subcommand with help then show help', (t) => {361+ const { program } = makeProgram(t);362 let exception;363 364 program365 .addOption(new commander.Option('--black'))3 unmodified lines369 program.parse('--white --black foo --help'.split(' '), { from: 'user' });370 } catch (err) {371 exception = err;372 }323- expect(exception).not.toBeUndefined();324- expect(exception.code).toBe('commander.helpDisplayed');373+ assert.notEqual(exception, undefined);374+ assert.equal(exception.code, 'commander.helpDisplayed');375 });376 327- test('when conflict on program calling external subcommand then throw conflict', () => {328- const { program } = makeProgram();377+ test('when conflict on program calling external subcommand then throw conflict', (t) => {378+ const { program } = makeProgram(t);379 let exception;380 381 program382 .addOption(new commander.Option('--black'))5 unmodified lines388 program.parse('--white --black ext'.split(' '), { from: 'user' });389 } catch (err) {390 exception = err;391 }342- expect(exception).not.toBeUndefined();343- expect(exception.code).toBe('commander.conflictingOption');392+ assert.notEqual(exception, undefined);393+ assert.equal(exception.code, 'commander.conflictingOption');394 });395 });modified:tests/options.custom-processing.test.js+30 added-27 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 function myParseInt(value, dummyPrevious) {6 // parseInt takes a string and a radix7 return parseInt(value, 10);10 unmodified lines18 function commaSeparatedList(value, dummyPrevious) {19 return value.split(',');20 }21 20-test('when option not specified then callback not called', () => {21- const mockCoercion = jest.fn();22+test('when option not specified then callback not called', (t) => {23+ const mockCoercion = t.mock.fn();24 const program = new commander.Command();25 program.option('-i, --integer <n>', 'number', mockCoercion);26 program.parse(['node', 'test']);25- expect(mockCoercion).not.toHaveBeenCalled();27+ assert.equal(mockCoercion.mock.callCount(), 0);28 });29 30 test('when option not specified then value is undefined', () => {31 const program = new commander.Command();32 program.option('-i, --integer <n>', 'number', myParseInt);33 program.parse(['node', 'test']);32- expect(program.opts().integer).toBeUndefined();34+ assert.equal(program.opts().integer, undefined);35 });36 35-test('when starting value is defined and option not specified then callback not called', () => {36- const mockCoercion = jest.fn();37+test('when starting value is defined and option not specified then callback not called', (t) => {38+ const mockCoercion = t.mock.fn();39 const program = new commander.Command();40 program.option('-i, --integer <n>', 'number', mockCoercion, 1);41 program.parse(['node', 'test']);40- expect(mockCoercion).not.toHaveBeenCalled();42+ assert.equal(mockCoercion.mock.callCount(), 0);43 });44 45 test('when starting value is defined and option not specified then value is starting value', () => {46 // NB: Can not specify a starting value for a boolean flag! Discovered when writing this test...47 const startingValue = 1;48 const program = new commander.Command();49 program.option('-i, --integer <n>', 'number', myParseInt, startingValue);50 program.parse(['node', 'test']);49- expect(program.opts().integer).toBe(startingValue);51+ assert.equal(program.opts().integer, startingValue);52 });53 52-test('when option specified then callback called with value', () => {53- const mockCoercion = jest.fn();54+test('when option specified then callback called with value and previous', (t) => {55+ const mockCoercion = t.mock.fn();56 const value = '1';57 const program = new commander.Command();58 program.option('-i, --integer <n>', 'number', mockCoercion);59 program.parse(['node', 'test', '-i', value]);58- expect(mockCoercion).toHaveBeenCalledWith(value, undefined);60+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, [value, undefined]);61 });62 63 test('when option specified then value is as returned from callback', () => {64 const callbackResult = 2;1 unmodified line66 program.option('-i, --integer <n>', 'number', () => {67 return callbackResult;68 });69 program.parse(['node', 'test', '-i', '0']);68- expect(program.opts().integer).toBe(callbackResult);70+ assert.equal(program.opts().integer, callbackResult);71 });72 71-test('when starting value is defined and option specified then callback called with value and starting value', () => {72- const mockCoercion = jest.fn();73+test('when starting value is defined and option specified then callback called with value and starting value', (t) => {74+ const mockCoercion = t.mock.fn();75 const startingValue = 1;76 const value = '2';77 const program = new commander.Command();78 program.option('-i, --integer <n>', 'number', mockCoercion, startingValue);79 program.parse(['node', 'test', '-i', value]);78- expect(mockCoercion).toHaveBeenCalledWith(value, startingValue);80+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, [81+ value,82+ startingValue,83+ ]);84 });85 81-test('when option specified multiple times then callback called with value and previousValue', () => {82- const mockCoercion = jest.fn().mockImplementation(() => {83- return 'callback';84- });86+test('when option specified multiple times then callback called with value and previousValue', (t) => {87+ const mockCoercion = t.mock.fn(() => 'callback');88 const program = new commander.Command();89 program.option('-i, --integer <n>', 'number', mockCoercion);90 program.parse(['node', 'test', '-i', '1', '-i', '2']);88- expect(mockCoercion).toHaveBeenCalledTimes(2);89- expect(mockCoercion).toHaveBeenNthCalledWith(1, '1', undefined);90- expect(mockCoercion).toHaveBeenNthCalledWith(2, '2', 'callback');91+ assert.equal(mockCoercion.mock.callCount(), 2);92+ assert.deepEqual(mockCoercion.mock.calls[0].arguments, ['1', undefined]);93+ assert.deepEqual(mockCoercion.mock.calls[1].arguments, ['2', 'callback']);94 });95 96 // Now some functional tests like the examples in the README!97 98 test('when parseFloat "1e2" then value is 100', () => {99 const program = new commander.Command();100 program.option('-f, --float <number>', 'float argument', parseFloat);101 program.parse(['node', 'test', '-f', '1e2']);99- expect(program.opts().float).toBe(100);102+ assert.equal(program.opts().float, 100);103 });104 105 test('when myParseInt "1" then value is 1', () => {106 const program = new commander.Command();107 program.option('-i, --integer <number>', 'integer argument', myParseInt);108 program.parse(['node', 'test', '-i', '1']);106- expect(program.opts().integer).toBe(1);109+ assert.equal(program.opts().integer, 1);110 });111 112 test('when increaseVerbosity -v -v -v then value is 3', () => {113 const program = new commander.Command();3 unmodified lines117 increaseVerbosity,118 0,119 );120 program.parse(['node', 'test', '-v', '-v', '-v']);118- expect(program.opts().verbose).toBe(3);121+ assert.equal(program.opts().verbose, 3);122 });123 124 test('when collect -c a -c b -c c then value is [a, b, c]', () => {125 const program = new commander.Command();126 program.option('-c, --collect <value>', 'repeatable value', collect, []);127 program.parse(['node', 'test', '-c', 'a', '-c', 'b', '-c', 'c']);125- expect(program.opts().collect).toEqual(['a', 'b', 'c']);128+ assert.deepEqual(program.opts().collect, ['a', 'b', 'c']);129 });130 131 test('when commaSeparatedList x,y,z then value is [x, y, z]', () => {132 const program = new commander.Command();2 unmodified lines135 'comma separated list',136 commaSeparatedList,137 );138 program.parse(['node', 'test', '--list', 'x,y,z']);136- expect(program.opts().list).toEqual(['x', 'y', 'z']);139+ assert.deepEqual(program.opts().list, ['x', 'y', 'z']);140 });modified:tests/options.default.test.js+28 added-26 removed
1 const { Command, Option } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('.option() with default and option not specified in parse', () => {6 test('when boolean option with boolean default then value is default', () => {7 const program = new Command();8 program.option('-d, --debug', 'description', false);9 program.parse([], { from: 'user' });8- expect(program.opts().debug).toBe(false);10+ assert.equal(program.opts().debug, false);11 });12 13 test('when boolean option with number zero default then value is zero', () => {14 const program = new Command();15 program.option('-d, --debug', 'description', 0);16 program.parse([], { from: 'user' });15- expect(program.opts().debug).toBe(0);17+ assert.equal(program.opts().debug, 0);18 });19 20 test('when boolean option with string default then value is default', () => {21 const program = new Command();22 program.option('-d, --debug', 'description', 'default');23 program.parse([], { from: 'user' });22- expect(program.opts().debug).toBe('default');24+ assert.equal(program.opts().debug, 'default');25 });26 27 test('when required option-argument and default number then value is default', () => {28 const program = new Command();29 program.option('-p, --port <port-number>', 'description', 80);30 program.parse([], { from: 'user' });29- expect(program.opts().port).toBe(80);31+ assert.equal(program.opts().port, 80);32 });33 34 test('when required option-argument and default string then value is default', () => {35 const program = new Command();36 program.option('-p, --port <port-number>', 'description', 'foo');37 program.parse([], { from: 'user' });36- expect(program.opts().port).toBe('foo');38+ assert.equal(program.opts().port, 'foo');39 });40 41 test('when optional option-argument and default number then value is default', () => {42 const program = new Command();43 program.option('-p, --port [port-number]', 'description', 80);44 program.parse([], { from: 'user' });43- expect(program.opts().port).toBe(80);45+ assert.equal(program.opts().port, 80);46 });47 48 test('when optional option-argument and default string then value is default', () => {49 const program = new Command();50 program.option('-p, --port [port-number]', 'description', 'foo');51 program.parse([], { from: 'user' });50- expect(program.opts().port).toBe('foo');52+ assert.equal(program.opts().port, 'foo');53 });54 55 test('when negated and default string then value is default', () => {56 // Bit tricky thinking about what default means for a negated option, but treat as with other options.57 const program = new Command();58 program.option('--no-colour', 'description', 'RGB');59 program.parse([], { from: 'user' });58- expect(program.opts().colour).toBe('RGB');60+ assert.equal(program.opts().colour, 'RGB');61 });62 });63 64 describe('Option with default and option not specified in parse', () => {65 test('when boolean option with boolean default then value is default', () => {66 const program = new Command();67 program.addOption(new Option('-d, --debug').default(false));68 program.parse([], { from: 'user' });67- expect(program.opts().debug).toBe(false);69+ assert.equal(program.opts().debug, false);70 });71 72 test('when boolean option with number zero default then value is zero', () => {73 const program = new Command();74 program.addOption(new Option('-d, --debug').default(0));75 program.parse([], { from: 'user' });74- expect(program.opts().debug).toBe(0);76+ assert.equal(program.opts().debug, 0);77 });78 79 test('when boolean option with string default then value is default', () => {80 const program = new Command();81 program.addOption(new Option('-d, --debug').default('default'));82 program.parse([], { from: 'user' });81- expect(program.opts().debug).toBe('default');83+ assert.equal(program.opts().debug, 'default');84 });85 86 test('when required option-argument and default number then value is default', () => {87 const program = new Command();88 program.addOption(new Option('-p, --port <port-number>').default(80));89 program.parse([], { from: 'user' });88- expect(program.opts().port).toBe(80);90+ assert.equal(program.opts().port, 80);91 });92 93 test('when required option-argument and default string then value is default', () => {94 const program = new Command();95 program.addOption(new Option('-p, --port <port-number>').default('foo'));96 program.parse([], { from: 'user' });95- expect(program.opts().port).toBe('foo');97+ assert.equal(program.opts().port, 'foo');98 });99 100 test('when optional option-argument and default number then value is default', () => {101 const program = new Command();102 program.addOption(new Option('-p, --port [port-number]').default(80));103 program.parse([], { from: 'user' });102- expect(program.opts().port).toBe(80);104+ assert.equal(program.opts().port, 80);105 });106 107 test('when optional option-argument and default string then value is default', () => {108 const program = new Command();109 program.addOption(new Option('-p, --port [port-number]').default('foo'));110 program.parse([], { from: 'user' });109- expect(program.opts().port).toBe('foo');111+ assert.equal(program.opts().port, 'foo');112 });113 114 test('when negated and default string then value is default', () => {115 // Bit tricky thinking about what default means for a negated option, but treat as with other options.116 const program = new Command();117 program.addOption(new Option('--no-colour').default('RGB'));118 program.parse([], { from: 'user' });117- expect(program.opts().colour).toBe('RGB');119+ assert.equal(program.opts().colour, 'RGB');120 });121 });122 123 // Fairly obvious this needs to happen, but was broken for optional in past!1 unmodified line125 test('when boolean option with boolean default then value is true', () => {126 const program = new Command();127 program.option('-d, --debug', 'description', false);128 program.parse(['-d'], { from: 'user' });127- expect(program.opts().debug).toBe(true);129+ assert.equal(program.opts().debug, true);130 });131 132 test('when boolean option with number zero default then value is true', () => {133 const program = new Command();134 program.option('-d, --debug', 'description', 0);135 program.parse(['-d'], { from: 'user' });134- expect(program.opts().debug).toBe(true);136+ assert.equal(program.opts().debug, true);137 });138 139 test('when boolean option with string default then value is true', () => {140 const program = new Command();141 program.option('-d, --debug', 'description', 'default');142 program.parse(['-d'], { from: 'user' });141- expect(program.opts().debug).toBe(true);143+ assert.equal(program.opts().debug, true);144 });145 146 test('when required option-argument and default number then value is from args', () => {147 const program = new Command();148 program.option('-p, --port <port-number>', 'description', 80);149 program.parse(['-p', '1234'], { from: 'user' });148- expect(program.opts().port).toBe('1234');150+ assert.equal(program.opts().port, '1234');151 });152 153 test('when required option-argument and default string then value is from args', () => {154 const program = new Command();155 program.option('-p, --port <port-number>', 'description', 'foo');156 program.parse(['-p', '1234'], { from: 'user' });155- expect(program.opts().port).toBe('1234');157+ assert.equal(program.opts().port, '1234');158 });159 160 test('when optional option-argument and default number and option-argument specified then value is from args', () => {161 const program = new Command();162 program.option('-p, --port [port-number]', 'description', 80);163 program.parse(['-p', '1234'], { from: 'user' });162- expect(program.opts().port).toBe('1234');164+ assert.equal(program.opts().port, '1234');165 });166 167 test('when optional option-argument and default string and option-argument specified then value is from args', () => {168 const program = new Command();169 program.option('-p, --port [port-number]', 'description', 'foo');170 program.parse(['-p', '1234'], { from: 'user' });169- expect(program.opts().port).toBe('1234');171+ assert.equal(program.opts().port, '1234');172 });173 174 test('when optional option-argument and default number and option-argument not specified then value is true', () => {175 const program = new Command();176 program.option('-p, --port [port-number]', 'description', 80);177 program.parse(['-p'], { from: 'user' });176- expect(program.opts().port).toBe(true);178+ assert.equal(program.opts().port, true);179 });180 181 test('when optional option-argument and default string and option-argument not specified then value is true', () => {182 const program = new Command();183 program.option('-p, --port [port-number]', 'description', 'foo');184 program.parse(['-p'], { from: 'user' });183- expect(program.opts().port).toBe(true);185+ assert.equal(program.opts().port, true);186 });187 188 test('when negated and default string then value is false', () => {189 // Bit tricky thinking about what default means for a negated option, but treat as with other options.190 const program = new Command();191 program.option('--no-colour', 'description', 'RGB');192 program.parse(['--no-colour'], { from: 'user' });191- expect(program.opts().colour).toBe(false);193+ assert.equal(program.opts().colour, false);194 });195 });modified:tests/options.dual-options.test.js+19 added-17 removed
1 const { Option, DualOptions } = require('../lib/option.js');2 const { Command } = require('../');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // This tests an internal helper class which is not currently exposed on the package.7 8 test('when positive option then stored in positiveOptions', () => {9 const program = new Command();10 program.option('--one');11 const helper = new DualOptions(program.options);10- expect(helper.positiveOptions.size).toEqual(1);11- expect(helper.negativeOptions.size).toEqual(0);12- expect(helper.dualOptions.size).toEqual(0);12+ assert.equal(helper.positiveOptions.size, 1);13+ assert.equal(helper.negativeOptions.size, 0);14+ assert.equal(helper.dualOptions.size, 0);15 });16 17 test('when negative option then stored in negativeOptions', () => {18 const program = new Command();19 program.option('--no-one');20 const helper = new DualOptions(program.options);19- expect(helper.positiveOptions.size).toEqual(0);20- expect(helper.negativeOptions.size).toEqual(1);21- expect(helper.dualOptions.size).toEqual(0);21+ assert.equal(helper.positiveOptions.size, 0);22+ assert.equal(helper.negativeOptions.size, 1);23+ assert.equal(helper.dualOptions.size, 0);24 });25 26 test('when unrelated positive and negative options then no dual options', () => {27 const program = new Command();28 program.option('--one').option('--no-two');29 const helper = new DualOptions(program.options);28- expect(helper.dualOptions.size).toEqual(0);30+ assert.equal(helper.dualOptions.size, 0);31 });32 33 test('when related positive and negative options then stored as dual option', () => {34 const program = new Command();35 program.option('--one').option('--no-one');36 const helper = new DualOptions(program.options);35- expect(helper.dualOptions.size).toEqual(1);37+ assert.equal(helper.dualOptions.size, 1);38 });39 40 test('when related negative and positive options then stored as dual option', () => {41 const program = new Command();42 program.option('--no-one').option('--one');43 const helper = new DualOptions(program.options);42- expect(helper.dualOptions.size).toEqual(1);44+ assert.equal(helper.dualOptions.size, 1);45 });46 47 describe('valueFromOption with boolean option', () => {48 const positiveOption = new Option('--one');1 unmodified line50 const options = [positiveOption, negativeOption];51 52 test('when negativeOption with false then return true', () => {53 const helper = new DualOptions(options);52- expect(helper.valueFromOption(false, negativeOption)).toBe(true);54+ assert.equal(helper.valueFromOption(false, negativeOption), true);55 });56 57 test('when negativeOption with true then return false', () => {58 const helper = new DualOptions(options);57- expect(helper.valueFromOption(true, negativeOption)).toBe(false);59+ assert.equal(helper.valueFromOption(true, negativeOption), false);60 });61 62 test('when positiveOption with false then return false', () => {63 const helper = new DualOptions(options);62- expect(helper.valueFromOption(false, positiveOption)).toBe(false);64+ assert.equal(helper.valueFromOption(false, positiveOption), false);65 });66 67 test('when positiveOption with true then return true', () => {68 const helper = new DualOptions(options);67- expect(helper.valueFromOption(true, positiveOption)).toBe(true);69+ assert.equal(helper.valueFromOption(true, positiveOption), true);70 });71 });72 73 describe('valueFromOption with option expecting value and negative with preset', () => {2 unmodified lines76 const options = [positiveOption, negativeOption];77 78 test('when negativeOption with FALSE then return true', () => {79 const helper = new DualOptions(options);78- expect(helper.valueFromOption('FALSE', negativeOption)).toBe(true);80+ assert.equal(helper.valueFromOption('FALSE', negativeOption), true);81 });82 83 test('when negativeOption with string then return false', () => {84 const helper = new DualOptions(options);83- expect(helper.valueFromOption('foo', negativeOption)).toBe(false);85+ assert.equal(helper.valueFromOption('foo', negativeOption), false);86 });87 88 test('when positiveOption with FALSE then return false', () => {89 const helper = new DualOptions(options);88- expect(helper.valueFromOption('FALSE', positiveOption)).toBe(false);90+ assert.equal(helper.valueFromOption('FALSE', positiveOption), false);91 });92 93 test('when positiveOption with true then return true', () => {94 const helper = new DualOptions(options);93- expect(helper.valueFromOption('foo', positiveOption)).toBe(true);95+ assert.equal(helper.valueFromOption('foo', positiveOption), true);96 });97 });modified:tests/options.env.test.js+125 added-117 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // treating optional same as required, treat as option taking value rather than as boolean6+describe('option declared with value', () => {4-describe.each(['-f, --foo <required-arg>', '-f, --foo [optional-arg]'])(5- 'option declared as: %s',6- (fooFlags) => {7- test('when env undefined and no cli then option undefined', () => {8- const program = new commander.Command();9- program.addOption(new commander.Option(fooFlags).env('BAR'));10- program.parse([], { from: 'user' });11- expect(program.opts().foo).toBeUndefined();12- });7+ const flagsList = ['-f, --foo <required-arg>', '-f, --foo [optional-arg]'];8+ for (const fooFlags of flagsList) {9+ describe(`option declared as: ${fooFlags}`, () => {10+ test('when env undefined and no cli then option undefined', () => {11+ const program = new commander.Command();12+ program.addOption(new commander.Option(fooFlags).env('BAR'));13+ program.parse([], { from: 'user' });14+ assert.equal(program.opts().foo, undefined);15+ });16 14- test('when env defined and no cli then option from env', () => {15- const program = new commander.Command();16- process.env.BAR = 'env';17- program.addOption(new commander.Option(fooFlags).env('BAR'));18- program.parse([], { from: 'user' });19- expect(program.opts().foo).toBe('env');20- delete process.env.BAR;21- });17+ test('when env defined and no cli then option from env', () => {18+ const program = new commander.Command();19+ process.env.BAR = 'env';20+ program.addOption(new commander.Option(fooFlags).env('BAR'));21+ program.parse([], { from: 'user' });22+ assert.equal(program.opts().foo, 'env');23+ delete process.env.BAR;24+ });25 23- test('when env defined and cli then option from cli', () => {24- const program = new commander.Command();25- process.env.BAR = 'env';26- program.addOption(new commander.Option(fooFlags).env('BAR'));27- program.parse(['--foo', 'cli'], { from: 'user' });28- expect(program.opts().foo).toBe('cli');29- delete process.env.BAR;30- });26+ test('when env defined and cli then option from cli', () => {27+ const program = new commander.Command();28+ process.env.BAR = 'env';29+ program.addOption(new commander.Option(fooFlags).env('BAR'));30+ program.parse(['--foo', 'cli'], { from: 'user' });31+ assert.equal(program.opts().foo, 'cli');32+ delete process.env.BAR;33+ });34 32- test('when env defined and value source is config then option from env', () => {33- const program = new commander.Command();34- process.env.BAR = 'env';35- program.addOption(new commander.Option(fooFlags).env('BAR'));36- program.setOptionValueWithSource('foo', 'config', 'config');37- program.parse([], { from: 'user' });38- expect(program.opts().foo).toBe('env');39- delete process.env.BAR;40- });35+ test('when env defined and value source is config then option from env', () => {36+ const program = new commander.Command();37+ process.env.BAR = 'env';38+ program.addOption(new commander.Option(fooFlags).env('BAR'));39+ program.setOptionValueWithSource('foo', 'config', 'config');40+ program.parse([], { from: 'user' });41+ assert.equal(program.opts().foo, 'env');42+ delete process.env.BAR;43+ });44 42- test('when env defined and value source is unspecified then option unchanged', () => {43- const program = new commander.Command();44- process.env.BAR = 'env';45- program.addOption(new commander.Option(fooFlags).env('BAR'));46- program.setOptionValue('foo', 'client');47- program.parse([], { from: 'user' });48- expect(program.opts().foo).toBe('client');49- delete process.env.BAR;50- });45+ test('when env defined and value source is unspecified then option unchanged', () => {46+ const program = new commander.Command();47+ process.env.BAR = 'env';48+ program.addOption(new commander.Option(fooFlags).env('BAR'));49+ program.setOptionValue('foo', 'client');50+ program.parse([], { from: 'user' });51+ assert.equal(program.opts().foo, 'client');52+ delete process.env.BAR;53+ });54 52- test('when default and env undefined and no cli then option from default', () => {53- const program = new commander.Command();54- program.addOption(55- new commander.Option(fooFlags).env('BAR').default('default'),56- );57- program.parse([], { from: 'user' });58- expect(program.opts().foo).toBe('default');59- });55+ test('when default and env undefined and no cli then option from default', () => {56+ const program = new commander.Command();57+ program.addOption(58+ new commander.Option(fooFlags).env('BAR').default('default'),59+ );60+ program.parse([], { from: 'user' });61+ assert.equal(program.opts().foo, 'default');62+ });63 61- test('when default and env defined and no cli then option from env', () => {62- const program = new commander.Command();63- process.env.BAR = 'env';64- program.addOption(65- new commander.Option(fooFlags).env('BAR').default('default'),66- );67- program.parse([], { from: 'user' });68- expect(program.opts().foo).toBe('env');69- delete process.env.BAR;70- });64+ test('when default and env defined and no cli then option from env', () => {65+ const program = new commander.Command();66+ process.env.BAR = 'env';67+ program.addOption(68+ new commander.Option(fooFlags).env('BAR').default('default'),69+ );70+ program.parse([], { from: 'user' });71+ assert.equal(program.opts().foo, 'env');72+ delete process.env.BAR;73+ });74 72- test('when default and env defined and cli then option from cli', () => {73- const program = new commander.Command();74- process.env.BAR = 'env';75- program.addOption(76- new commander.Option(fooFlags).env('BAR').default('default'),77- );78- program.parse(['--foo', 'cli'], { from: 'user' });79- expect(program.opts().foo).toBe('cli');80- delete process.env.BAR;75+ test('when default and env defined and cli then option from cli', () => {76+ const program = new commander.Command();77+ process.env.BAR = 'env';78+ program.addOption(79+ new commander.Option(fooFlags).env('BAR').default('default'),80+ );81+ program.parse(['--foo', 'cli'], { from: 'user' });82+ assert.equal(program.opts().foo, 'cli');83+ delete process.env.BAR;84+ });85 });82- },83-);86+ }87+});88 89 describe('boolean flag', () => {90 test('when env undefined and no cli then option undefined', () => {91 const program = new commander.Command();92 program.addOption(new commander.Option('-f, --foo').env('BAR'));93 program.parse([], { from: 'user' });90- expect(program.opts().foo).toBeUndefined();94+ assert.equal(program.opts().foo, undefined);95 });96 97 test('when env defined with value and no cli then option true', () => {98 const program = new commander.Command();99 process.env.BAR = 'env';100 program.addOption(new commander.Option('-f, --foo').env('BAR'));101 program.parse([], { from: 'user' });98- expect(program.opts().foo).toBe(true);102+ assert.equal(program.opts().foo, true);103 delete process.env.BAR;104 });105 106 test('when env is "" and no cli then option true', () => {1 unmodified line108 const program = new commander.Command();109 process.env.BAR = '';110 program.addOption(new commander.Option('-f, --foo').env('BAR'));111 program.parse([], { from: 'user' });108- expect(program.opts().foo).toBe(true);112+ assert.equal(program.opts().foo, true);113 delete process.env.BAR;114 });115 116 test('when env is "0" and no cli then option true', () => {1 unmodified line118 const program = new commander.Command();119 process.env.BAR = '0';120 program.addOption(new commander.Option('-f, --foo').env('BAR'));121 program.parse([], { from: 'user' });118- expect(program.opts().foo).toBe(true);122+ assert.equal(program.opts().foo, true);123 delete process.env.BAR;124 });125 126 test('when env is "false" and no cli then option true', () => {1 unmodified line128 const program = new commander.Command();129 process.env.BAR = 'false';130 program.addOption(new commander.Option('-f, --foo').env('BAR'));131 program.parse([], { from: 'user' });128- expect(program.opts().foo).toBe(true);132+ assert.equal(program.opts().foo, true);133 delete process.env.BAR;134 });135 });136 1 unmodified line138 test('when env undefined and no cli then option true', () => {139 const program = new commander.Command();140 program.addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));141 program.parse([], { from: 'user' });138- expect(program.opts().foo).toBe(true);142+ assert.equal(program.opts().foo, true);143 });144 145 test('when env defined and no cli then option false', () => {146 const program = new commander.Command();147 process.env.NO_BAR = 'env';148 program.addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));149 program.parse([], { from: 'user' });146- expect(program.opts().foo).toBe(false);150+ assert.equal(program.opts().foo, false);151 delete process.env.NO_BAR;152 });153 });154 3 unmodified lines158 program159 .addOption(new commander.Option('-f, --foo').env('BAR'))160 .addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));161 program.parse([], { from: 'user' });158- expect(program.opts().foo).toBeUndefined();162+ assert.equal(program.opts().foo, undefined);163 });164 165 test('when env defined and no cli then option true', () => {166 const program = new commander.Command();1 unmodified line168 program169 .addOption(new commander.Option('-f, --foo').env('BAR'))170 .addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));171 program.parse([], { from: 'user' });168- expect(program.opts().foo).toBe(true);172+ assert.equal(program.opts().foo, true);173 delete process.env.BAR;174 });175 176 test('when env defined and cli --no-foo then option false', () => {2 unmodified lines179 program180 .addOption(new commander.Option('-f, --foo').env('BAR'))181 .addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));182 program.parse(['--no-foo'], { from: 'user' });179- expect(program.opts().foo).toBe(false);183+ assert.equal(program.opts().foo, false);184 delete process.env.BAR;185 });186 187 test('when no_env defined and no cli then option false', () => {2 unmodified lines190 program191 .addOption(new commander.Option('-f, --foo').env('BAR'))192 .addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));193 program.parse([], { from: 'user' });190- expect(program.opts().foo).toBe(false);194+ assert.equal(program.opts().foo, false);195 delete process.env.NO_BAR;196 });197 198 test('when no_env defined and cli --foo then option true', () => {2 unmodified lines201 program202 .addOption(new commander.Option('-f, --foo').env('BAR'))203 .addOption(new commander.Option('-F, --no-foo').env('NO_BAR'));204 program.parse(['--foo'], { from: 'user' });201- expect(program.opts().foo).toBe(true);205+ assert.equal(program.opts().foo, true);206 delete process.env.NO_BAR;207 });208 });209 6 unmodified lines216 .env('BAR')217 .argParser((str) => str.toUpperCase()),218 );219 program.parse([], { from: 'user' });216- expect(program.opts().foo).toBe('ENV');220+ assert.equal(program.opts().foo, 'ENV');221 delete process.env.BAR;222 });223 });224 4 unmodified lines229 program.addOption(230 new commander.Option('-f, --foo <required...>').env('BAR'),231 );232 program.parse([], { from: 'user' });229- expect(program.opts().foo).toEqual(['env']);233+ assert.deepEqual(program.opts().foo, ['env']);234 delete process.env.BAR;235 });236 237 test('when env defined and cli then array from cli', () => {2 unmodified lines240 program.addOption(241 new commander.Option('-f, --foo <required...>').env('BAR'),242 );243 program.parse(['--foo', 'cli'], { from: 'user' });240- expect(program.opts().foo).toEqual(['cli']);244+ assert.deepEqual(program.opts().foo, ['cli']);245 delete process.env.BAR;246 });247 });248 11 unmodified lines260 .default('default'),261 )262 .action(() => {});263 program.parse(['one'], { from: 'user' });260- expect(two.opts().foo).toBe('default');264+ assert.equal(two.opts().foo, 'default');265 delete process.env.BAR;266 });267 264- test('when env and cli defined then only emit option event for cli', () => {268+ test('when env and cli defined then only emit option event for cli', (t) => {269 const program = new commander.Command();266- const optionEventMock = jest.fn();267- const optionEnvEventMock = jest.fn();270+ const optionEventMock = t.mock.fn();271+ const optionEnvEventMock = t.mock.fn();272 program.on('option:foo', optionEventMock);273 program.on('optionEnv:foo', optionEnvEventMock);274 process.env.BAR = 'env';275 program.addOption(276 new commander.Option('-f, --foo <required...>').env('BAR'),277 );278 program.parse(['--foo', 'cli'], { from: 'user' });275- expect(optionEventMock).toHaveBeenCalledWith('cli');276- expect(optionEventMock).toHaveBeenCalledTimes(1);277- expect(optionEnvEventMock).toHaveBeenCalledTimes(0);279+ assert.equal(optionEventMock.mock.calls[0].arguments[0], 'cli');280+ assert.equal(optionEventMock.mock.callCount(), 1);281+ assert.equal(optionEnvEventMock.mock.callCount(), 0);282 delete process.env.BAR;283 });284 281- test('when env and cli defined then only parse value for cli', () => {285+ test('when env and cli defined then only parse value for cli', (t) => {286 const program = new commander.Command();283- const parseMock = jest.fn();287+ const parseMock = t.mock.fn();288 process.env.BAR = 'env';289 program.addOption(290 new commander.Option('-f, --foo <required...>')291 .env('BAR')292 .argParser(parseMock),293 );294 program.parse(['--foo', 'cli'], { from: 'user' });291- expect(parseMock).toHaveBeenCalledWith('cli', undefined);292- expect(parseMock).toHaveBeenCalledTimes(1);295+ assert.equal(parseMock.mock.calls[0].arguments[0], 'cli');296+ assert.equal(parseMock.mock.calls[0].arguments[1], undefined);297+ assert.equal(parseMock.mock.callCount(), 1);298 delete process.env.BAR;299 });300 });301 302 describe('events dispatched for env', () => {298- const optionEnvEventMock = jest.fn();299-300- afterEach(() => {301- optionEnvEventMock.mockClear();302- delete process.env.BAR;303- });304-305- test('when env defined then emit "optionEnv" and not "option"', () => {303+ test('when env defined then emit "optionEnv" and not "option"', (t) => {304 // Decided to do separate events, so test stays that way.305 const program = new commander.Command();308- const optionEventMock = jest.fn();306+ const optionEventMock = t.mock.fn();307+ const optionEnvEventMock = t.mock.fn();308 program.on('option:foo', optionEventMock);309 program.on('optionEnv:foo', optionEnvEventMock);310 process.env.BAR = 'env';311 program.addOption(new commander.Option('-f, --foo <required>').env('BAR'));312 program.parse([], { from: 'user' });314- expect(optionEventMock).toHaveBeenCalledTimes(0);315- expect(optionEnvEventMock).toHaveBeenCalledTimes(1);313+ assert.equal(optionEventMock.mock.callCount(), 0);314+ assert.equal(optionEnvEventMock.mock.callCount(), 1);315+ delete process.env.BAR;316 });317 318- test('when env defined for required then emit "optionEnv" with value', () => {318+ test('when env defined for required then emit "optionEnv" with value', (t) => {319 const program = new commander.Command();320+ const optionEnvEventMock = t.mock.fn();321 program.on('optionEnv:foo', optionEnvEventMock);322 process.env.BAR = 'env';323 program.addOption(new commander.Option('-f, --foo <required>').env('BAR'));324 program.parse([], { from: 'user' });324- expect(optionEnvEventMock).toHaveBeenCalledWith('env');325+ assert.equal(optionEnvEventMock.mock.calls[0].arguments[0], 'env');326+ delete process.env.BAR;327 });328 327- test('when env defined for optional then emit "optionEnv" with value', () => {329+ test('when env defined for optional then emit "optionEnv" with value', (t) => {330 const program = new commander.Command();331+ const optionEnvEventMock = t.mock.fn();332 program.on('optionEnv:foo', optionEnvEventMock);333 process.env.BAR = 'env';334 program.addOption(new commander.Option('-f, --foo [optional]').env('BAR'));335 program.parse([], { from: 'user' });333- expect(optionEnvEventMock).toHaveBeenCalledWith('env');336+ assert.equal(optionEnvEventMock.mock.calls[0].arguments[0], 'env');337+ delete process.env.BAR;338 });339 336- test('when env defined for boolean then emit "optionEnv" with no param', () => {340+ test('when env defined for boolean then emit "optionEnv" with no param', (t) => {341 // check matches historical boolean action event342 const program = new commander.Command();343+ const optionEnvEventMock = t.mock.fn();344 program.on('optionEnv:foo', optionEnvEventMock);345 process.env.BAR = 'anything';346 program.addOption(new commander.Option('-f, --foo').env('BAR'));347 program.parse([], { from: 'user' });343- expect(optionEnvEventMock).toHaveBeenCalledWith();348+ assert.equal(optionEnvEventMock.mock.calls[0].arguments.length, 0);349+ delete process.env.BAR;350 });351 346- test('when env defined for negated boolean then emit "optionEnv" with no param', () => {352+ test('when env defined for negated boolean then emit "optionEnv" with no param', (t) => {353 // check matches historical boolean action event354 const program = new commander.Command();355+ const optionEnvEventMock = t.mock.fn();356 program.on('optionEnv:no-foo', optionEnvEventMock);357 process.env.BAR = 'anything';358 program.addOption(new commander.Option('-F, --no-foo').env('BAR'));359 program.parse([], { from: 'user' });353- expect(optionEnvEventMock).toHaveBeenCalledWith();360+ assert.equal(optionEnvEventMock.mock.calls[0].arguments.length, 0);361+ delete process.env.BAR;362 });363 });modified:tests/options.flags.test.js+12 added-10 removed
1 const commander = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test the various ways flags can be specified in the first parameter to `.option`6 7 test('when only short flag defined and not specified then value is undefined', () => {8 const program = new commander.Command();9 program.option('-p', 'add pepper');10 program.parse(['node', 'test']);9- expect(program.opts().p).toBeUndefined();11+ assert.equal(program.opts().p, undefined);12 });13 14 test('when only short flag defined and specified then value is true', () => {15 const program = new commander.Command();16 program.option('-p', 'add pepper');17 program.parse(['node', 'test', '-p']);16- expect(program.opts().p).toBe(true);18+ assert.equal(program.opts().p, true);19 });20 21 test('when only long flag defined and not specified then value is undefined', () => {22 const program = new commander.Command();23 program.option('--pepper', 'add pepper');24 program.parse(['node', 'test']);23- expect(program.opts().pepper).toBeUndefined();25+ assert.equal(program.opts().pepper, undefined);26 });27 28 test('when only long flag defined and specified then value is true', () => {29 const program = new commander.Command();30 program.option('--pepper', 'add pepper');31 program.parse(['node', 'test', '--pepper']);30- expect(program.opts().pepper).toBe(true);32+ assert.equal(program.opts().pepper, true);33 });34 35 test('when "short,long" flags defined and short specified then value is true', () => {36 const program = new commander.Command();37 program.option('-p,--pepper', 'add pepper');38 program.parse(['node', 'test', '-p']);37- expect(program.opts().pepper).toBe(true);39+ assert.equal(program.opts().pepper, true);40 });41 42 test('when "short,long" flags defined and long specified then value is true', () => {43 const program = new commander.Command();44 program.option('-p,--pepper', 'add pepper');45 program.parse(['node', 'test', '--pepper']);44- expect(program.opts().pepper).toBe(true);46+ assert.equal(program.opts().pepper, true);47 });48 49 test('when "short|long" flags defined and short specified then value is true', () => {50 const program = new commander.Command();51 program.option('-p|--pepper', 'add pepper');52 program.parse(['node', 'test', '-p']);51- expect(program.opts().pepper).toBe(true);53+ assert.equal(program.opts().pepper, true);54 });55 56 test('when "short|long" flags defined and long specified then value is true', () => {57 const program = new commander.Command();58 program.option('-p|--pepper', 'add pepper');59 program.parse(['node', 'test', '--pepper']);58- expect(program.opts().pepper).toBe(true);60+ assert.equal(program.opts().pepper, true);61 });62 63 test('when "short long" flags defined and short specified then value is true', () => {64 const program = new commander.Command();65 program.option('-p --pepper', 'add pepper');66 program.parse(['node', 'test', '-p']);65- expect(program.opts().pepper).toBe(true);67+ assert.equal(program.opts().pepper, true);68 });69 70 test('when "short long" flags defined and long specified then value is true', () => {71 const program = new commander.Command();72 program.option('-p --pepper', 'add pepper');73 program.parse(['node', 'test', '--pepper']);72- expect(program.opts().pepper).toBe(true);74+ assert.equal(program.opts().pepper, true);75 });modified:tests/options.getset.test.js+17 added-15 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 3-describe.each([true, false])(4- 'storeOptionsAsProperties is %s',5- (storeOptionsAsProperties) => {6- test('when option specified on CLI then value returned by getOptionValue', () => {5+describe('storeOptionsAsProperties', () => {6+ const storeOptionsAsPropertiesList = [true, false];7+ for (const storeOptionsAsProperties of storeOptionsAsPropertiesList) {8+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and option specified on CLI then value returned by getOptionValue`, () => {9 const program = new commander.Command();10 program11 .storeOptionsAsProperties(storeOptionsAsProperties)12 .option('--cheese [type]', 'cheese type');13 const cheeseType = 'blue';14 program.parse(['node', 'test', '--cheese', cheeseType]);13- expect(program.getOptionValue('cheese')).toBe(cheeseType);15+ assert.equal(program.getOptionValue('cheese'), cheeseType);16 });17 16- test('when setOptionValue then value returned by opts', () => {18+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and setOptionValue then value returned by opts`, () => {19 const program = new commander.Command();20 const cheeseType = 'blue';21 // Note: opts() only returns declared options when options stored as properties22 program23 .storeOptionsAsProperties(storeOptionsAsProperties)24 .option('--cheese [type]', 'cheese type')25 .setOptionValue('cheese', cheeseType);24- expect(program.opts().cheese).toBe(cheeseType);26+ assert.equal(program.opts().cheese, cheeseType);27 });26- },27-);28+ }29+});30 31 test('when setOptionValueWithSource then value returned by opts', () => {32 const program = new commander.Command();33 const cheeseValue = 'blue';34 program35 .option('--cheese [type]', 'cheese type')36 .setOptionValueWithSource('cheese', cheeseValue, 'cli');35- expect(program.opts().cheese).toBe(cheeseValue);37+ assert.equal(program.opts().cheese, cheeseValue);38 });39 40 test('when setOptionValueWithSource then source returned by getOptionValueSource', () => {41 const program = new commander.Command();42 program43 .option('--cheese [type]', 'cheese type')44 .setOptionValueWithSource('cheese', 'blue', 'config');43- expect(program.getOptionValueSource('cheese')).toBe('config');45+ assert.equal(program.getOptionValueSource('cheese'), 'config');46 });47 48 test('when option value parsed from env then option source is env', () => {49 const program = new commander.Command();50 process.env.BAR = 'env';51 program.addOption(new commander.Option('-f, --foo').env('BAR'));52 program.parse([], { from: 'user' });51- expect(program.getOptionValueSource('foo')).toBe('env');53+ assert.equal(program.getOptionValueSource('foo'), 'env');54 delete process.env.BAR;55 });56 57 test('when option value parsed from cli then option source is cli', () => {58 const program = new commander.Command();59 program.addOption(new commander.Option('-f, --foo').env('BAR'));60 program.parse(['--foo'], { from: 'user' });59- expect(program.getOptionValueSource('foo')).toBe('cli');61+ assert.equal(program.getOptionValueSource('foo'), 'cli');62 });63 64 test('when setOptionValue then clears previous source', () => {65 const program = new commander.Command();66 program.option('--foo', 'description', 'default value');65- expect(program.getOptionValueSource('foo')).toBe('default');67+ assert.equal(program.getOptionValueSource('foo'), 'default');68 program.setOptionValue('foo', 'bar');67- expect(program.getOptionValueSource('foo')).toBeUndefined();69+ assert.equal(program.getOptionValueSource('foo'), undefined);70 });modified:tests/options.implies.test.js+28 added-29 removed
1 const { Command, Option } = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 describe('check priorities', () => {7 test('when source undefined and implied undefined then implied is undefined', () => {8 const program = new Command();9 program10 .addOption(new Option('--foo').implies({ bar: 'implied' }))11 .option('--bar');12 program.parse([], { from: 'user' });10- expect(program.opts()).toEqual({});13+ assert.deepEqual(program.opts(), {});14 });15 16 test('when source default and implied undefined then implied is undefined', () => {17 const program = new Command();2 unmodified lines20 new Option('--foo').implies({ bar: 'implied' }).default('default'),21 )22 .option('--bar');23 program.parse([], { from: 'user' });21- expect(program.opts()).toEqual({ foo: 'default' });24+ assert.deepEqual(program.opts(), { foo: 'default' });25 });26 27 test('when source from env and implied undefined then implied is implied', () => {28 const program = new Command();2 unmodified lines31 program32 .addOption(new Option('--foo').implies({ bar: 'implied' }).env(envName))33 .option('--bar');34 program.parse([], { from: 'user' });32- expect(program.opts()).toEqual({ foo: true, bar: 'implied' });35+ assert.deepEqual(program.opts(), { foo: true, bar: 'implied' });36 delete process.env[envName];37 });38 39 test('when source from cli and implied undefined then implied is implied', () => {1 unmodified line41 program42 .addOption(new Option('--foo').implies({ bar: 'implied' }))43 .option('--bar');44 program.parse(['--foo'], { from: 'user' });42- expect(program.opts()).toEqual({ foo: true, bar: 'implied' });45+ assert.deepEqual(program.opts(), { foo: true, bar: 'implied' });46 });47 48 test('when source cli and implied default then implied is implied', () => {49 const program = new Command();50 program51 .addOption(new Option('--foo').implies({ bar: 'implied' }))52 .option('--bar', '', 'default');53 program.parse(['--foo'], { from: 'user' });51- expect(program.opts()).toEqual({ foo: true, bar: 'implied' });54+ assert.deepEqual(program.opts(), { foo: true, bar: 'implied' });55 });56 57 test('when source cli and env default then implied is env', () => {58 const program = new Command();2 unmodified lines61 program62 .addOption(new Option('--foo').implies({ bar: 'implied' }))63 .addOption(new Option('--bar <value>').env(envName));64 program.parse(['--foo'], { from: 'user' });62- expect(program.opts()).toEqual({ foo: true, bar: 'env' });65+ assert.deepEqual(program.opts(), { foo: true, bar: 'env' });66 delete process.env[envName];67 });68 });69 70 test('when imply non-option then ok and stored', () => {71 const program = new Command();72 program.addOption(new Option('--foo').implies({ bar: 'implied' }));73 program.parse(['--foo'], { from: 'user' });71- expect(program.opts()).toEqual({ foo: true, bar: 'implied' });74+ assert.deepEqual(program.opts(), { foo: true, bar: 'implied' });75 });76 77 test('when imply multiple values then store multiple values', () => {78 const program = new Command();1 unmodified line80 .addOption(new Option('--foo').implies({ one: 'ONE', two: 'TWO' }))81 .option('--one')82 .option('--two');83 program.parse(['--foo'], { from: 'user' });81- expect(program.opts()).toEqual({ foo: true, one: 'ONE', two: 'TWO' });84+ assert.deepEqual(program.opts(), { foo: true, one: 'ONE', two: 'TWO' });85 });86 87 test('when imply multiple times then store multiple values', () => {88 const program = new Command();3 unmodified lines92 )93 .option('--one')94 .option('--two');95 program.parse(['--foo'], { from: 'user' });93- expect(program.opts()).toEqual({ foo: true, one: 'ONE', two: 'TWO' });96+ assert.deepEqual(program.opts(), { foo: true, one: 'ONE', two: 'TWO' });97 });98 99 test('when imply from positive option then positive implied', () => {100 const program = new Command();101 program102 .addOption(new Option('--foo').implies({ implied: 'POSITIVE' }))103 .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));104 program.parse(['--foo'], { from: 'user' });102- expect(program.opts()).toEqual({ foo: true, implied: 'POSITIVE' });105+ assert.deepEqual(program.opts(), { foo: true, implied: 'POSITIVE' });106 });107 108 test('when imply from negative option then negative implied', () => {109 const program = new Command();110 program111 .addOption(new Option('--foo').implies({ implied: 'POSITIVE' }))112 .addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));113 program.parse(['--no-foo'], { from: 'user' });111- expect(program.opts()).toEqual({ foo: false, implied: 'NEGATIVE' });114+ assert.deepEqual(program.opts(), { foo: false, implied: 'NEGATIVE' });115 });116 117 test('when imply from lone negative option then negative implied', () => {118 const program = new Command();119 program.addOption(new Option('--no-foo').implies({ implied: 'NEGATIVE' }));120 program.parse(['--no-foo'], { from: 'user' });118- expect(program.opts()).toEqual({ foo: false, implied: 'NEGATIVE' });121+ assert.deepEqual(program.opts(), { foo: false, implied: 'NEGATIVE' });122 });123 124 test('when imply from negative option with preset then negative implied', () => {125 const program = new Command();2 unmodified lines128 .addOption(129 new Option('--no-foo').implies({ implied: 'NEGATIVE' }).preset('FALSE'),130 );131 program.parse(['--no-foo'], { from: 'user' });129- expect(program.opts()).toEqual({ foo: 'FALSE', implied: 'NEGATIVE' });132+ assert.deepEqual(program.opts(), { foo: 'FALSE', implied: 'NEGATIVE' });133 });134 135 test('when chained implies then only explicitly trigger', () => {136 const program = new Command();1 unmodified line138 .addOption(new Option('--one').implies({ two: true }))139 .addOption(new Option('--two').implies({ three: true }))140 .addOption(new Option('--three'));141 program.parse(['--one'], { from: 'user' });139- expect(program.opts()).toEqual({ one: true, two: true });142+ assert.deepEqual(program.opts(), { one: true, two: true });143 });144 145 test('when looped implies then no infinite loop', () => {146 const program = new Command();147 program148 .addOption(new Option('--ying').implies({ yang: true }))149 .addOption(new Option('--yang').implies({ ying: true }));150 program.parse(['--ying'], { from: 'user' });148- expect(program.opts()).toEqual({ ying: true, yang: true });151+ assert.deepEqual(program.opts(), { ying: true, yang: true });152 });153 154 test('when conflict with implied value then throw', () => {152- const program = new Command();155+ const program = createTestCommand();156 program154- .exitOverride()155- .configureOutput({156- writeErr: () => {},157- })157 .addOption(new Option('--unary'))158 .addOption(new Option('--binary').conflicts('unary'))159 .addOption(new Option('--one').implies({ unary: true }));160 162- expect(() => {161+ assert.throws(() => {162 program.parse(['--binary', '--one'], { from: 'user' });164- }).toThrow();163+ });164 });165 166 test('when requiredOption with implied value then not throw', () => {167 const program = new Command();2 unmodified lines170 .addOption(171 new Option('--default-target').implies({ target: 'default-file' }),172 );173 175- expect(() => {174+ assert.doesNotThrow(() => {175 program.parse(['--default-target'], { from: 'user' });177- }).not.toThrow();176+ });177 });178 179 test('when implies on program and use subcommand then program updated', () => {180 const program = new Command();181 program.addOption(new Option('--foo').implies({ bar: 'implied' }));182 program.command('sub').action(() => {});183 program.parse(['--foo', 'sub'], { from: 'user' });185- expect(program.opts().bar).toEqual('implied');184+ assert.equal(program.opts().bar, 'implied');185 });186 187 test('when option with implies used multiple times then implied gets single value', () => {188 const program = new Command();189 program190 .addOption(new Option('--foo').implies({ bar: 'implied' }))191 .option('-b, --bar <value...>');192 program.parse(['--foo', '--foo'], { from: 'user' });194- expect(program.opts().bar).toEqual('implied');193+ assert.deepEqual(program.opts().bar, 'implied');194 });195 196 test('when implied option has custom processing then custom processing not called', () => {197 let called = false;3 unmodified lines201 .option('-b, --bar', 'description', () => {202 called = true;203 });204 program.parse(['--foo'], { from: 'user' });206- expect(program.opts().bar).toEqual(true);207- expect(called).toEqual(false);205+ assert.equal(program.opts().bar, true);206+ assert.equal(called, false);207 });208 209 test('when passed string then treat as boolean', () => {210 // Do something sensible instead of something silly if user passes just name of option.2 unmodified lines213 program214 .addOption(new Option('--foo').implies('bar'))215 .option('-b, --bar', 'description');216 program.parse(['--foo'], { from: 'user' });218- expect(program.opts().bar).toEqual(true);217+ assert.equal(program.opts().bar, true);218 });modified:tests/options.mandatory.test.js+62 added-131 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // Assuming mandatory options behave as normal options apart from the mandatory aspect, not retesting all behaviour.7 // Likewise, not redoing all tests on subcommand after testing on program.8 9 describe('required program option with mandatory value specified', () => {10 test('when program has required value specified then value as specified', () => {11 const program = new commander.Command();9- program.exitOverride().requiredOption('--cheese <type>', 'cheese type');12+ program.requiredOption('--cheese <type>', 'cheese type');13 program.parse(['node', 'test', '--cheese', 'blue']);11- expect(program.opts().cheese).toBe('blue');14+ assert.equal(program.opts().cheese, 'blue');15 });16 17 test('when program has option with name different than property then still recognised', () => {18 const program = new commander.Command();16- program17- .exitOverride()18- .requiredOption('--cheese-type <type>', 'cheese type');19+ program.requiredOption('--cheese-type <type>', 'cheese type');20 program.parse(['node', 'test', '--cheese-type', 'blue']);20- expect(program.opts().cheeseType).toBe('blue');21+ assert.equal(program.opts().cheeseType, 'blue');22 });23 24 test('when program has required value default then default value', () => {25 const program = new commander.Command();25- program26- .exitOverride()27- .requiredOption('--cheese <type>', 'cheese type', 'default');26+ program.requiredOption('--cheese <type>', 'cheese type', 'default');27 program.parse(['node', 'test']);29- expect(program.opts().cheese).toBe('default');28+ assert.equal(program.opts().cheese, 'default');29 });30 31 test('when program has optional value flag specified then true', () => {32 const program = new commander.Command();34- program.exitOverride().requiredOption('--cheese [type]', 'cheese type');33+ program.requiredOption('--cheese [type]', 'cheese type');34 program.parse(['node', 'test', '--cheese']);36- expect(program.opts().cheese).toBe(true);35+ assert.equal(program.opts().cheese, true);36 });37 38 test('when program has optional value default then default value', () => {39 const program = new commander.Command();41- program42- .exitOverride()43- .requiredOption('--cheese [type]', 'cheese type', 'default');40+ program.requiredOption('--cheese [type]', 'cheese type', 'default');41 program.parse(['node', 'test']);45- expect(program.opts().cheese).toBe('default');42+ assert.equal(program.opts().cheese, 'default');43 });44 45 test('when program has value/no flag specified with value then specified value', () => {46 const program = new commander.Command();47 program51- .exitOverride()48 .requiredOption('--cheese <type>', 'cheese type')49 .requiredOption('--no-cheese', 'no cheese thanks');50 program.parse(['node', 'test', '--cheese', 'blue']);55- expect(program.opts().cheese).toBe('blue');51+ assert.equal(program.opts().cheese, 'blue');52 });53 54 test('when program has mandatory-yes/no flag specified with flag then true', () => {55 const program = new commander.Command();56 program61- .exitOverride()57 .requiredOption('--cheese', 'cheese type')58 .option('--no-cheese', 'no cheese thanks');59 program.parse(['node', 'test', '--cheese']);65- expect(program.opts().cheese).toBe(true);60+ assert.equal(program.opts().cheese, true);61 });62 63 test('when program has mandatory-yes/mandatory-no flag specified with flag then true', () => {64 const program = new commander.Command();65 program71- .exitOverride()66 .requiredOption('--cheese', 'cheese type')67 .requiredOption('--no-cheese', 'no cheese thanks');68 program.parse(['node', 'test', '--cheese']);75- expect(program.opts().cheese).toBe(true);69+ assert.equal(program.opts().cheese, true);70 });71 72 test('when program has yes/no flag specified negated then false', () => {73 const program = new commander.Command();74 program81- .exitOverride()75 .requiredOption('--cheese <type>', 'cheese type')76 .option('--no-cheese', 'no cheese thanks');77 program.parse(['node', 'test', '--no-cheese']);85- expect(program.opts().cheese).toBe(false);78+ assert.equal(program.opts().cheese, false);79 });80 81 test('when program has required value specified and subcommand then specified value', () => {82 const program = new commander.Command();83 program91- .exitOverride()84 .requiredOption('--cheese <type>', 'cheese type')85 .command('sub')86 .action(() => {});87 program.parse(['node', 'test', '--cheese', 'blue', 'sub']);96- expect(program.opts().cheese).toBe('blue');88+ assert.equal(program.opts().cheese, 'blue');89 });90 });91 92 describe('required program option with mandatory value not specified', () => {101- // Optional. Use internal knowledge to suppress output to keep test output clean.102- let writeErrorSpy;103-104- beforeAll(() => {105- writeErrorSpy = jest106- .spyOn(process.stderr, 'write')107- .mockImplementation(() => {});108- });109-110- afterEach(() => {111- writeErrorSpy.mockClear();112- });113-114- afterAll(() => {115- writeErrorSpy.mockRestore();116- });117-93 test('when program has required option not specified then error', () => {119- const program = new commander.Command();120- program.exitOverride().requiredOption('--cheese <type>', 'cheese type');94+ const program = createTestCommand();95+ program.requiredOption('--cheese <type>', 'cheese type');96 122- expect(() => {97+ assert.throws(() => {98 program.parse(['node', 'test']);124- }).toThrow();99+ });100 });101 102 test('when program has optional option not specified then error', () => {128- const program = new commander.Command();129- program.exitOverride().requiredOption('--cheese [type]', 'cheese type');103+ const program = createTestCommand();104+ program.requiredOption('--cheese [type]', 'cheese type');105 131- expect(() => {106+ assert.throws(() => {107 program.parse(['node', 'test']);133- }).toThrow();108+ });109 });110 111 test('when program has yes/no not specified then error', () => {137- const program = new commander.Command();112+ const program = createTestCommand();113 program139- .exitOverride()114 .requiredOption('--cheese', 'cheese type')115 .option('--no-cheese', 'no cheese thanks');116 143- expect(() => {117+ assert.throws(() => {118 program.parse(['node', 'test']);145- }).toThrow();119+ });120 });121 122 test('when program has required value not specified and subcommand then error', () => {149- const program = new commander.Command();123+ const program = createTestCommand();124 program151- .exitOverride()125 .requiredOption('--cheese <type>', 'cheese type')126 .command('sub')127 .action(() => {});128 156- expect(() => {129+ assert.throws(() => {130 program.parse(['node', 'test', 'sub']);158- }).toThrow();131+ });132 });133 });134 135 describe('required command option with mandatory value specified', () => {136 test('when command has required value specified then no error and option has specified value', () => {164- const program = new commander.Command();137+ const program = createTestCommand();138 let cmdOptions;139 program167- .exitOverride()140 .command('sub')141 .requiredOption('--subby <type>', 'description')142 .action((options) => {143 cmdOptions = options;144 });145 146 program.parse(['node', 'test', 'sub', '--subby', 'blue']);147 176- expect(cmdOptions.subby).toBe('blue');148+ assert.equal(cmdOptions.subby, 'blue');149 });150 151 test('when command has required value specified using env then no error and option has specified value', () => {180- const program = new commander.Command();181- program182- .exitOverride()183- .addOption(184- new commander.Option('-p, --port <number>', 'port number')185- .makeOptionMandatory()186- .env('FOO'),187- );152+ const program = createTestCommand();153+ program.addOption(154+ new commander.Option('-p, --port <number>', 'port number')155+ .makeOptionMandatory()156+ .env('FOO'),157+ );158 159 process.env.FOO = 'bar';160 program.parse([], { from: 'user' });161 delete process.env.FOO;162 193- expect(program.opts().port).toBe('bar');163+ assert.equal(program.opts().port, 'bar');164 });165 });166 167 describe('required command option with mandatory value not specified', () => {198- // Optional. Use internal knowledge to suppress output to keep test output clean.199- let writeErrorSpy;200-201- beforeAll(() => {202- writeErrorSpy = jest203- .spyOn(process.stderr, 'write')204- .mockImplementation(() => {});205- });206-207- afterEach(() => {208- writeErrorSpy.mockClear();209- });210-211- afterAll(() => {212- writeErrorSpy.mockRestore();213- });214-168 test('when command has required value not specified then error', () => {216- const program = new commander.Command();169+ const program = createTestCommand();170 program218- .exitOverride()171 .command('sub')172 .requiredOption('--subby <type>', 'description')173 .action(() => {});174 223- expect(() => {175+ assert.throws(() => {176 program.parse(['node', 'test', 'sub']);225- }).toThrow();177+ });178 });179 180 test('when command has required value but not called then no error', () => {229- const program = new commander.Command();181+ const program = createTestCommand();182 program231- .exitOverride()183 .command('sub')184 .requiredOption('--subby <type>', 'description')185 .action(() => {});186 program.command('sub2');187 237- expect(() => {188+ assert.doesNotThrow(() => {189 program.parse(['node', 'test', 'sub2']);239- }).not.toThrow();190+ });191 });192 });193 194 describe('missing mandatory option but help requested', () => {244- // Optional. Use internal knowledge to suppress output to keep test output clean.245- let writeSpy;246-247- beforeAll(() => {248- writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => {});249- });250-251- afterEach(() => {252- writeSpy.mockClear();253- });254-255- afterAll(() => {256- writeSpy.mockRestore();257- });258-195 test('when program has required option not specified and --help then help', () => {260- const program = new commander.Command();261- program.exitOverride().requiredOption('--cheese <type>', 'cheese type');196+ const program = createTestCommand();197+ program.requiredOption('--cheese <type>', 'cheese type');198 263- let caughtErr;264- try {265- program.parse(['node', 'test', '--help']);266- } catch (err) {267- caughtErr = err;268- }269-270- expect(caughtErr.code).toEqual('commander.helpDisplayed');199+ assert.throws(200+ () => {201+ program.parse(['node', 'test', '--help']);202+ },203+ { code: 'commander.helpDisplayed' },204+ );205 });206 207 test('when program has required option not specified and subcommand --help then help', () => {274- const program = new commander.Command();208+ const program = createTestCommand();209 program276- .exitOverride()210 .requiredOption('--cheese <type>', 'cheese type')211 .command('sub')212 .action(() => {});213 281- let caughtErr;282- try {283- program.parse(['node', 'test', 'sub', '--help']);284- } catch (err) {285- caughtErr = err;286- }287-288- expect(caughtErr.code).toEqual('commander.helpDisplayed');214+ assert.throws(215+ () => {216+ program.parse(['node', 'test', 'sub', '--help']);217+ },218+ { code: 'commander.helpDisplayed' },219+ );220 });221 });modified:tests/options.optional.test.js+10 added-8 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // option with optional value, no default6 describe('option with optional value, no default', () => {7 test('when option not specified then value is undefined', () => {8 const program = new commander.Command();9 program.option('--cheese [type]', 'cheese type');10 program.parse(['node', 'test']);9- expect(program.opts().cheese).toBeUndefined();11+ assert.equal(program.opts().cheese, undefined);12 });13 14 test('when option specified then value is as specified', () => {15 const program = new commander.Command();16 program.option('--cheese [type]', 'cheese type');17 const cheeseType = 'blue';18 program.parse(['node', 'test', '--cheese', cheeseType]);17- expect(program.opts().cheese).toBe(cheeseType);19+ assert.equal(program.opts().cheese, cheeseType);20 });21 22 test('when option specified without value then value is true', () => {23 const program = new commander.Command();24 program.option('--cheese [type]', 'cheese type');25 program.parse(['node', 'test', '--cheese']);24- expect(program.opts().cheese).toBe(true);26+ assert.equal(program.opts().cheese, true);27 });28 29 test('when option specified without value and following option then value is true', () => {30 // optional options do not eat values with dashes31 const program = new commander.Command();32 program.option('--cheese [type]', 'cheese type').option('--some-option');33 program.parse(['node', 'test', '--cheese', '--some-option']);32- expect(program.opts().cheese).toBe(true);34+ assert.equal(program.opts().cheese, true);35 });36 });37 38 // option with optional value, with default2 unmodified lines41 const defaultValue = 'default';42 const program = new commander.Command();43 program.option('--cheese [type]', 'cheese type', defaultValue);44 program.parse(['node', 'test']);43- expect(program.opts().cheese).toBe(defaultValue);45+ assert.equal(program.opts().cheese, defaultValue);46 });47 48 test('when option specified then value is as specified', () => {49 const defaultValue = 'default';50 const program = new commander.Command();51 program.option('--cheese [type]', 'cheese type', defaultValue);52 const cheeseType = 'blue';53 program.parse(['node', 'test', '--cheese', cheeseType]);52- expect(program.opts().cheese).toBe(cheeseType);54+ assert.equal(program.opts().cheese, cheeseType);55 });56 57 test('when option specified without value then value is true', () => {58 const defaultValue = 'default';59 const program = new commander.Command();60 program.option('--cheese [type]', 'cheese type', defaultValue);61 program.parse(['node', 'test', '--cheese']);60- expect(program.opts().cheese).toBe(true);62+ assert.equal(program.opts().cheese, true);63 });64 65 test('when option specified without value and preset then value is preset', () => {66 const program = new commander.Command();67 program.addOption(new commander.Option('--cheese [type]').preset('preset'));68 program.parse(['node', 'test', '--cheese']);67- expect(program.opts().cheese).toBe('preset');69+ assert.equal(program.opts().cheese, 'preset');70 });71 });modified:tests/options.opts.test.js+21 added-17 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test the `.opts()` way of accessing option values.6 // Basic coverage of the main option types (leaving out negatable flags and options with optional values).7 1 unmodified line9 const program = new commander.Command();10 const version = '0.0.1';11 program.storeOptionsAsProperties().version(version);12 program.parse(['node', 'test']);11- expect(program.opts()).toEqual({ version });13+ assert.deepEqual(program.opts(), { version });14 });15 16 test('when .version used with storeOptionsAsProperties(false) then version not in opts', () => {17 // New behaviour, stop storing version as an option value.18 const program = new commander.Command();19 const version = '0.0.1';20 program.storeOptionsAsProperties(false).version(version);21 program.parse(['node', 'test']);20- expect(program.opts()).toEqual({});22+ assert.deepEqual(program.opts(), {});23 });24 23-describe.each([true, false])(24- 'storeOptionsAsProperties is %s',25- (storeOptionsAsProperties) => {26- test('when boolean flag not specified then not in opts', () => {25+describe('storeOptionsAsProperties', () => {26+ const storeOptionsAsPropertiesList = [true, false];27+ for (const storeOptionsAsProperties of storeOptionsAsPropertiesList) {28+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and boolean flag not specified then not in opts`, () => {29 const program = new commander.Command();30 program.storeOptionsAsProperties(storeOptionsAsProperties);31 program.option('--pepper', 'add pepper');32 program.parse(['node', 'test']);31- expect(program.opts()).toEqual({});33+ const expected = storeOptionsAsProperties ? { pepper: undefined } : {};34+ assert.deepEqual(program.opts(), expected);35 });36 34- test('when boolean flag specified then value true', () => {37+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and boolean flag specified then value true`, () => {38 const program = new commander.Command();39 program.storeOptionsAsProperties(storeOptionsAsProperties);40 program.option('--pepper', 'add pepper');41 program.parse(['node', 'test', '--pepper']);39- expect(program.opts()).toEqual({ pepper: true });42+ assert.deepEqual(program.opts(), { pepper: true });43 });44 42- test('when option with required value not specified then not in opts', () => {45+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and option with required value not specified then not in opts`, () => {46 const program = new commander.Command();47 program.storeOptionsAsProperties(storeOptionsAsProperties);48 program.option('--pepper <flavour>', 'add pepper');49 program.parse(['node', 'test']);47- expect(program.opts()).toEqual({});50+ const expected = storeOptionsAsProperties ? { pepper: undefined } : {};51+ assert.deepEqual(program.opts(), expected);52 });53 50- test('when option with required value specified then value as specified', () => {54+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and option with required value specified then value as specified`, () => {55 const pepperValue = 'red';56 const program = new commander.Command();57 program.storeOptionsAsProperties(storeOptionsAsProperties);58 program.option('--pepper <flavour>', 'add pepper');59 program.parse(['node', 'test', '--pepper', pepperValue]);56- expect(program.opts()).toEqual({ pepper: pepperValue });60+ assert.deepEqual(program.opts(), { pepper: pepperValue });61 });62 59- test('when option with default value not specified then default value in opts', () => {63+ test(`when storeOptionsAsProperties is ${storeOptionsAsProperties} and option with default value not specified then default value in opts`, () => {64 const pepperDefault = 'red';65 const program = new commander.Command();66 program.storeOptionsAsProperties(storeOptionsAsProperties);67 program.option('--pepper <flavour>', 'add pepper', pepperDefault);68 program.parse(['node', 'test']);65- expect(program.opts()).toEqual({ pepper: pepperDefault });69+ assert.deepEqual(program.opts(), { pepper: pepperDefault });70 });67- },68-);71+ }72+});modified:tests/options.optsWithGlobals.test.js+10 added-8 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Testing optsWithGlobals and getOptionValueSourceWithGlobals with focus on globals.6 7 describe('optsWithGlobals', () => {6 unmodified lines14 .option('-d, --default-value <value)', 'description', 'default value')15 .option('-n, --no-something');16 17 program.parse(['-b', '-r', 'req', '-f', '1e2'], { from: 'user' });16- expect(program.opts()).toEqual(program.optsWithGlobals());18+ assert.deepEqual(program.opts(), program.optsWithGlobals());19 });20 21 test('when options in sub and program then optsWithGlobals includes both', () => {22 const program = new commander.Command();6 unmodified lines29 mergedOptions = cmd.optsWithGlobals();30 });31 32 program.parse(['-g', 'GGG', 'sub', '-l', 'LLL'], { from: 'user' });31- expect(mergedOptions).toEqual({ global: 'GGG', local: 'LLL' });33+ assert.deepEqual(mergedOptions, { global: 'GGG', local: 'LLL' });34 });35 36 test('when options in sub and subsub then optsWithGlobals includes both', () => {37 const program = new commander.Command();9 unmodified lines47 48 program.parse(['sub', '-g', 'GGG', 'subsub', '-l', 'LLL'], {49 from: 'user',50 });49- expect(mergedOptions).toEqual({ global: 'GGG', local: 'LLL' });51+ assert.deepEqual(mergedOptions, { global: 'GGG', local: 'LLL' });52 });53 54 test('when same named option in sub and program then optsWithGlobals includes global', () => {55 const program = new commander.Command();6 unmodified lines62 mergedOptions = cmd.optsWithGlobals();63 });64 65 program.parse(['-c', 'GGG', 'sub', '-c', 'LLL'], { from: 'user' });64- expect(mergedOptions).toEqual({ common: 'GGG' });66+ assert.deepEqual(mergedOptions, { common: 'GGG' });67 });68 });69 70 describe('getOptionValueSourceWithGlobals', () => {1 unmodified line72 const program = new commander.Command();73 program.option('-g, --global');74 75 program.parse(['-g'], { from: 'user' });74- expect(program.getOptionValueSourceWithGlobals('global')).toEqual('cli');76+ assert.equal(program.getOptionValueSourceWithGlobals('global'), 'cli');77 });78 79 test('when option used with program then source is defined', () => {80 const program = new commander.Command();3 unmodified lines84 .option('-l, --local')85 .action(() => {});86 87 program.parse(['sub', '-g'], { from: 'user' });86- expect(sub.getOptionValueSourceWithGlobals('global')).toEqual('cli');88+ assert.equal(sub.getOptionValueSourceWithGlobals('global'), 'cli');89 });90 91 test('when option used with subcommand then source is defined', () => {92 const program = new commander.Command();3 unmodified lines96 .option('-l, --local')97 .action(() => {});98 99 program.parse(['sub', '-l'], { from: 'user' });98- expect(sub.getOptionValueSourceWithGlobals('local')).toEqual('cli');100+ assert.equal(sub.getOptionValueSourceWithGlobals('local'), 'cli');101 });102 103 test('when same named option in sub and program then source is defined by global', () => {104 const program = new commander.Command();5 unmodified lines110 .option('-c, --common <value>')111 .action(() => {});112 113 program.parse(['sub', '--common', 'value'], { from: 'user' });112- expect(sub.getOptionValueSourceWithGlobals('common')).toEqual('default');114+ assert.equal(sub.getOptionValueSourceWithGlobals('common'), 'default');115 });116 });modified:tests/options.preset.test.js+10 added-8 removed
1 const { Command, Option } = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 test('when boolean option with string preset used then value is preset', () => {6 const program = new Command();7 program.addOption(new Option('-d, --debug').preset('foo'));8 program.parse(['-d'], { from: 'user' });7- expect(program.opts().debug).toBe('foo');9+ assert.equal(program.opts().debug, 'foo');10 });11 12 test('when boolean option with number preset used then value is preset', () => {13 const program = new Command();14 program.addOption(new Option('-d, --debug').preset(80));15 program.parse(['-d'], { from: 'user' });14- expect(program.opts().debug).toBe(80);16+ assert.equal(program.opts().debug, 80);17 });18 19 test('when optional with string preset used then value is preset', () => {20 const program = new Command();21 program.addOption(new Option('-p, --port [port]').preset('foo'));22 program.parse(['-p'], { from: 'user' });21- expect(program.opts().port).toBe('foo');23+ assert.equal(program.opts().port, 'foo');24 });25 26 test('when optional with number preset used then value is preset', () => {27 const program = new Command();28 program.addOption(new Option('-p, --port [port]').preset(80));29 program.parse(['-p'], { from: 'user' });28- expect(program.opts().port).toBe(80);30+ assert.equal(program.opts().port, 80);31 });32 33 test('when optional with string preset used with option-argument then value is as specified', () => {34 const program = new Command();35 program.addOption(new Option('-p, --port [port]').preset('foo'));36 program.parse(['-p', '1234'], { from: 'user' });35- expect(program.opts().port).toBe('1234');37+ assert.equal(program.opts().port, '1234');38 });39 40 test('when optional with preset and coerce used then preset is coerced', () => {41 const program = new Command();42 program.addOption(43 new Option('-p, --port [port]').preset('4').argParser(parseFloat),44 );45 program.parse(['-p'], { from: 'user' });44- expect(program.opts().port).toBe(4);46+ assert.equal(program.opts().port, 4);47 });48 49 test('when optional with preset and variadic used then preset is concatenated', () => {50 const program = new Command();51 program.addOption(new Option('-n, --name [name...]').preset('two'));52 program.parse(['-n', 'one', '-n', '-n', 'three'], { from: 'user' });51- expect(program.opts().name).toEqual(['one', 'two', 'three']);53+ assert.deepEqual(program.opts().name, ['one', 'two', 'three']);54 });55 56 test('when negated with string preset used then value is preset', () => {57 const program = new Command();58 program.addOption(new Option('--no-colour').preset('foo'));59 program.parse(['--no-colour'], { from: 'user' });58- expect(program.opts().colour).toBe('foo');60+ assert.equal(program.opts().colour, 'foo');61 });modified:tests/options.registerClash.test.js+30 added-20 removed
1 const { Command, Option } = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('.option()', () => {6 test('when short option flag conflicts then throws', () => {7+ assert.throws(5- expect(() => {6- const program = new Command();7- program8- .option('-c, --cheese <type>', 'cheese type')9- .option('-c, --conflict');10- }).toThrow('Cannot add option');8+ () => {9+ const program = new Command();10+ program11+ .option('-c, --cheese <type>', 'cheese type')12+ .option('-c, --conflict');13+ },14+ {15+ message: /Cannot add option/,16+ },17+ );18 });19 20 test('when long option flag conflicts then throws', () => {21+ assert.throws(14- expect(() => {15- const program = new Command();16- program17- .option('-c, --cheese <type>', 'cheese type')18- .option('-H, --cheese');19- }).toThrow('Cannot add option');22+ () => {23+ const program = new Command();24+ program25+ .option('-c, --cheese <type>', 'cheese type')26+ .option('-H, --cheese');27+ },28+ { message: /Cannot add option/ },29+ );30 });31 32 test('when use help options separately then does not throw', () => {23- expect(() => {33+ assert.doesNotThrow(() => {34 const program = new Command();35 program.option('-h, --help', 'display help');26- }).not.toThrow();36+ });37 });38 39 test('when reuse flags in subcommand then does not throw', () => {30- expect(() => {40+ assert.doesNotThrow(() => {41 const program = new Command();42 program.option('-e, --example');43 program.command('sub').option('-e, --example');34- }).not.toThrow();44+ });45 });46 });47 48 describe('.addOption()', () => {49 test('when short option flags conflicts then throws', () => {40- expect(() => {50+ assert.throws(() => {51 const program = new Command();52 program53 .option('-c, --cheese <type>', 'cheese type')54 .addOption(new Option('-c, --conflict'));45- }).toThrow('Cannot add option');55+ });56 });57 58 test('when long option flags conflicts then throws', () => {49- expect(() => {59+ assert.throws(() => {60 const program = new Command();61 program62 .option('-c, --cheese <type>', 'cheese type')63 .addOption(new Option('-H, --cheese'));54- }).toThrow('Cannot add option');64+ });65 });66 });modified:tests/options.required.test.js+24 added-30 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 // option with required value, no default7 describe('option with required value, no default', () => {8 test('when option not specified then value is undefined', () => {9 const program = new commander.Command();10 program.option('--cheese <type>', 'cheese type');11 program.parse(['node', 'test']);9- expect(program.opts().cheese).toBeUndefined();12+ assert.equal(program.opts().cheese, undefined);13 });14 15 test('when option specified then value is as specified', () => {16 const program = new commander.Command();17 program.option('--cheese <type>', 'cheese type');18 const cheeseType = 'blue';19 program.parse(['node', 'test', '--cheese', cheeseType]);17- expect(program.opts().cheese).toBe(cheeseType);20+ assert.equal(program.opts().cheese, cheeseType);21 });22 23 test('when option value not specified then error', () => {21- // Arrange. Mock error routine to allow interception.22- const mockOptionMissingArgument = jest.fn(() => {23- throw new Error('optionMissingArgument');24- });25- const program = new commander.Command();24+ const program = createTestCommand();26- program.optionMissingArgument = mockOptionMissingArgument;25 program.option('--cheese <type>', 'cheese type');26 27 // Act. The throw is due to the above mock, and not default behaviour.30- expect(() => {31- program.parse(['node', 'test', '--cheese']);32- }).toThrow();33-34- // Assert35- expect(mockOptionMissingArgument).toHaveBeenCalled();28+ assert.throws(29+ () => {30+ program.parse(['node', 'test', '--cheese']);31+ },32+ {33+ code: 'commander.optionMissingArgument',34+ },35+ );36 });37 });38 39 // option with required value, with default2 unmodified lines42 const defaultValue = 'default';43 const program = new commander.Command();44 program.option('--cheese <type>', 'cheese type', defaultValue);45 program.parse(['node', 'test']);46- expect(program.opts().cheese).toBe(defaultValue);46+ assert.equal(program.opts().cheese, defaultValue);47 });48 49 test('when option specified then value is as specified', () => {50 const defaultValue = 'default';51 const program = new commander.Command();52 program.option('--cheese <type>', 'cheese type', defaultValue);53 const cheeseType = 'blue';54 program.parse(['node', 'test', '--cheese', cheeseType]);55- expect(program.opts().cheese).toBe(cheeseType);55+ assert.equal(program.opts().cheese, cheeseType);56 });57 58- test('when option value not specified then error', () => {59- // Arrange. Mock error routine to allow interception.60- const mockOptionMissingArgument = jest.fn(() => {61- throw new Error('optionMissingArgument');62- });58+ test('when option value not specified then error', (t) => {59 const defaultValue = 'default';64- const program = new commander.Command();65- program.optionMissingArgument = mockOptionMissingArgument;60+ const program = createTestCommand();61 program.option('--cheese <type>', 'cheese type', defaultValue);62 68- // Act. The throw is due to the above mock, and not default behaviour.69- expect(() => {70- program.parse(['node', 'test', '--cheese']);71- }).toThrow();72-73- // Assert74- expect(mockOptionMissingArgument).toHaveBeenCalled();63+ assert.throws(64+ () => {65+ program.parse(['node', 'test', '--cheese']);66+ },67+ { code: 'commander.optionMissingArgument' },68+ );69 });70 });modified:tests/options.twice.test.js+8 added-6 removed
1 const { Command, Option } = require('../');2+const { test } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test that when option specified twice, second use wins.6 // Seems pretty obvious for boolean options, but there was a bug before Commander v9.7 8 test('when boolean option used twice then value is true', () => {9 const program = new Command();10 program.option('-d, --debug');11 program.parse(['-d', '-d'], { from: 'user' });10- expect(program.opts().debug).toBe(true);12+ assert.equal(program.opts().debug, true);13 });14 15 test('when boolean option with default used twice then value is true', () => {16 const program = new Command();17 program.option('-d, --debug', 'description', 'foo');18 program.parse(['-d', '-d'], { from: 'user' });17- expect(program.opts().debug).toBe(true);19+ assert.equal(program.opts().debug, true);20 });21 22 test('when boolean option with preset used twice then value is preset', () => {23 const program = new Command();24 program.addOption(new Option('-d, --debug').preset('foo'));25 program.parse(['-d', '-d'], { from: 'user' });24- expect(program.opts().debug).toBe('foo');26+ assert.equal(program.opts().debug, 'foo');27 });28 29 test('when option with required argument used twice then value is from second use', () => {30 const program = new Command();31 program.option('-p, --port <port-number>');32 program.parse(['-p', '1', '-p', '2'], { from: 'user' });31- expect(program.opts().port).toBe('2');33+ assert.equal(program.opts().port, '2');34 });35 36 test('when option with optional argument used second time without value then value is true', () => {37 const program = new Command();38 program.option('--donate [amount]');39 program.parse(['--donate', '123', '--donate'], { from: 'user' });38- expect(program.opts().donate).toBe(true);40+ assert.equal(program.opts().donate, true);41 });42 43 test('when option with optional argument used second time with value then value is from second use', () => {44 const program = new Command();45 program.option('--donate [amount]');46 program.parse(['--donate', '--donate', '123'], { from: 'user' });45- expect(program.opts().donate).toBe('123');47+ assert.equal(program.opts().donate, '123');48 });modified:tests/options.values.test.js+22 added-19 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test the ways values can be specified for options.6 // See also references on "Utility Conventions" in command.parseOptions.test.js7 8 // options with required values can eat values starting with a dash, including just dash sometimes used as alias for stdin9 //8-// option with required value, using describe.each to test all matrix of values and tests9-describe.each([['str'], ['80'], ['-'], ['-5'], ['--flag']])(10- 'option with required value specified as %s',11- (value) => {10+// option with required value, using loop to test all matrix of values and tests11+describe('option with required value', () => {12+ const valuesList = [['str'], ['80'], ['-'], ['-5'], ['--flag']];13+14+ for (const [value] of valuesList) {15 function createPortProgram() {16 const program = new commander.Command();17 program.option('-p,--port <number>', 'specify port');18 return program;19 }20 18- test('when short flag followed by value then value is as specified', () => {21+ test(`when option with required value specified as ${value} and short flag followed by value then value is as specified`, () => {22 const program = createPortProgram();23 program.parse(['node', 'test', '-p', value]);21- expect(program.opts().port).toBe(value);24+ assert.equal(program.opts().port, value);25 });26 24- test('when short flag concatenated with value then value is as specified', () => {27+ test(`when option with required value specified as ${value} and short flag concatenated with value then value is as specified`, () => {28 const program = createPortProgram();29 program.parse(['node', 'test', `-p${value}`]);27- expect(program.opts().port).toBe(value);30+ assert.equal(program.opts().port, value);31 });32 30- test('when long flag followed by value then value is as specified', () => {33+ test(`when option with required value specified as ${value} and long flag followed by value then value is as specified`, () => {34 const program = createPortProgram();35 program.parse(['node', 'test', '--port', value]);33- expect(program.opts().port).toBe(value);36+ assert.equal(program.opts().port, value);37 });38 36- test('when long flag = value then value is as specified', () => {39+ test(`when option with required value specified as ${value} and long flag = value then value is as specified`, () => {40 const program = createPortProgram();41 program.parse(['node', 'test', `--port=${value}`]);39- expect(program.opts().port).toBe(value);42+ assert.equal(program.opts().port, value);43 });41- },42-);44+ }45+});46 47 // option with optional value48 describe('option with optional value', () => {49 function createPortProgram() {4 unmodified lines54 55 test('when short flag followed by value then value is as specified', () => {56 const program = createPortProgram();57 program.parse('node test -p 80'.split(' '));55- expect(program.opts().port).toBe('80');58+ assert.equal(program.opts().port, '80');59 });60 61 test('when short flag concatenated with value then value is as specified', () => {62 const program = createPortProgram();63 program.parse('node test -p80'.split(' '));61- expect(program.opts().port).toBe('80');64+ assert.equal(program.opts().port, '80');65 });66 67 test('when long flag followed by value then value is as specified', () => {68 const program = createPortProgram();69 program.parse('node test --port 80'.split(' '));67- expect(program.opts().port).toBe('80');70+ assert.equal(program.opts().port, '80');71 });72 73 test('when long flag = value then value is as specified', () => {74 const program = createPortProgram();75 program.parse('node test --port=80'.split(' '));73- expect(program.opts().port).toBe('80');76+ assert.equal(program.opts().port, '80');77 });78 79 test('when long flag followed empty string then value is empty string', () => {80 const program = createPortProgram();1 unmodified line82 '-c, --cheese [type]',83 'optionally specify the type of cheese',84 );85 program.parse(['node', 'test', '--cheese', '']);83- expect(program.opts().cheese).toBe('');86+ assert.equal(program.opts().cheese, '');87 });88 });modified:tests/options.variadic.test.js+24 added-24 removed
1 const commander = require('../');2+const { createTestCommand } = require('./testHelpers');3+const { test, describe } = require('node:test');4+const assert = require('node:assert/strict');5 6 describe('variadic option with required value', () => {7 test('when variadic with value missing then error', () => {5- const program = new commander.Command();6- program7- .exitOverride()8- .configureOutput({ writeErr: jest.fn() })9- .option('-r,--required <value...>');8+ const program = createTestCommand();9+ program.option('-r,--required <value...>');10 11- expect(() => {11+ assert.throws(() => {12 program.parse(['--required'], { from: 'user' });13- }).toThrow();13+ });14 });15 16 test('when variadic with one value then set in array', () => {17 const program = new commander.Command();18 program.option('-r,--required <value...>');19 20 program.parse(['--required', 'one'], { from: 'user' });21- expect(program.opts().required).toEqual(['one']);21+ assert.deepEqual(program.opts().required, ['one']);22 });23 24 test('when variadic with two values then set in array', () => {25 const program = new commander.Command();26 program.option('-r,--required <value...>');27 28 program.parse(['--required', 'one', 'two'], { from: 'user' });29- expect(program.opts().required).toEqual(['one', 'two']);29+ assert.deepEqual(program.opts().required, ['one', 'two']);30 });31 32 test('when variadic with repeated values then set in array', () => {33 const program = new commander.Command();34 program.option('-r,--required <value...>');35 36 program.parse(['--required', 'one', '--required', 'two'], { from: 'user' });37- expect(program.opts().required).toEqual(['one', 'two']);37+ assert.deepEqual(program.opts().required, ['one', 'two']);38 });39 40 test('when variadic used with choices and one value then set in array', () => {41 const program = new commander.Command();1 unmodified line43 new commander.Option('-r,--required <value...>').choices(['one', 'two']),44 );45 46 program.parse(['--required', 'one'], { from: 'user' });47- expect(program.opts().required).toEqual(['one']);47+ assert.deepEqual(program.opts().required, ['one']);48 });49 50 test('when variadic used with choices and two values then set in array', () => {51 const program = new commander.Command();1 unmodified line53 new commander.Option('-r,--required <value...>').choices(['one', 'two']),54 );55 56 program.parse(['--required', 'one', 'two'], { from: 'user' });57- expect(program.opts().required).toEqual(['one', 'two']);57+ assert.deepEqual(program.opts().required, ['one', 'two']);58 });59 60 test('when variadic with short combined argument then not variadic', () => {61 const program = new commander.Command();62 program.option('-r,--required <value...>').argument('[arg]');63 64 program.parse(['-rone', 'operand'], { from: 'user' });65- expect(program.opts().required).toEqual(['one']);65+ assert.deepEqual(program.opts().required, ['one']);66 });67 68 test('when variadic with long combined argument then not variadic', () => {69 const program = new commander.Command();70 program.option('-r,--required <value...>').argument('[arg]');71 72 program.parse(['--required=one', 'operand'], { from: 'user' });73- expect(program.opts().required).toEqual(['one']);73+ assert.deepEqual(program.opts().required, ['one']);74 });75 76 test('when variadic with value followed by option then option not eaten', () => {77 const program = new commander.Command();3 unmodified lines81 .argument('[arg]');82 83 program.parse(['-r', 'one', '-f'], { from: 'user' });84 const opts = program.opts();85- expect(opts.required).toEqual(['one']);86- expect(opts.flag).toBe(true);85+ assert.deepEqual(opts.required, ['one']);86+ assert.equal(opts.flag, true);87 });88 89 test('when variadic with no value and default then set to default', () => {90 const program = new commander.Command();3 unmodified lines94 'default',95 );96 97 program.parse([], { from: 'user' });98- expect(program.opts().required).toEqual('default');98+ assert.equal(program.opts().required, 'default');99 });100 101 test('when variadic with coercion then coercion sets value', () => {102 const program = new commander.Command();4 unmodified lines107 );108 109 // variadic processing reads the multiple values, but up to custom coercion what it does.110 program.parse(['--required', '1e2', '1e3'], { from: 'user' });111- expect(program.opts().required).toEqual(1000);111+ assert.equal(program.opts().required, 1000);112 });113 });114 115 // Not retesting everything, but do some tests on variadic with optional2 unmodified lines118 const program = new commander.Command();119 program.option('-o,--optional [value...]');120 121 program.parse([], { from: 'user' });122- expect(program.opts().optional).toBeUndefined();122+ assert.equal(program.opts().optional, undefined);123 });124 125 test('when variadic used as boolean flag then value true', () => {126 const program = new commander.Command();127 program.option('-o,--optional [value...]');128 129 program.parse(['--optional'], { from: 'user' });130- expect(program.opts().optional).toBe(true);130+ assert.equal(program.opts().optional, true);131 });132 133 test('when variadic with one value then set in array', () => {134 const program = new commander.Command();135 program.option('-o,--optional [value...]');136 137 program.parse(['--optional', 'one'], { from: 'user' });138- expect(program.opts().optional).toEqual(['one']);138+ assert.deepEqual(program.opts().optional, ['one']);139 });140 141 test('when variadic with two values then set in array', () => {142 const program = new commander.Command();143 program.option('-o,--optional [value...]');144 145 program.parse(['--optional', 'one', 'two'], { from: 'user' });146- expect(program.opts().optional).toEqual(['one', 'two']);146+ assert.deepEqual(program.opts().optional, ['one', 'two']);147 });148 });149 150 describe('variadic special cases', () => {151 test('when option flags has word character before dots then is variadic', () => {152 const program = new commander.Command();153 program.option('-c,--comma [value...]');154 155- expect(program.options[0].variadic).toBeTruthy();155+ assert.equal(program.options[0].variadic, true);156 });157 158 test('when option flags has special characters before dots then not variadic', () => {159 // This might be used to describe coercion for comma separated values, and is not variadic.160 const program = new commander.Command();161 program.option('-c,--comma [value,...]');162 163- expect(program.options[0].variadic).toBeFalsy();163+ assert.equal(program.options[0].variadic, false);164 });165 });modified:tests/options.version.test.js+61 added-53 removed
1 const commander = require('../');2+const { test, describe } = require('node:test');3+const assert = require('node:assert/strict');4 5 // Test .version. Using exitOverride to check behaviour (instead of mocking process.exit).6 7 describe('.version', () => {8 test('when no .version and specify --version then unknown option error', () => {7- const errorMessage = 'unknownOption';9 const program = new commander.Command();9- // Override unknownOption as convenient way to check fails as expected.10- jest.spyOn(program, 'unknownOption').mockImplementation(() => {11- throw new Error(errorMessage);12- });10+ program.exitOverride().configureOutput({ writeErr: () => {} });11 14- expect(() => {15- program.parse(['node', 'test', '--version']);16- }).toThrow(errorMessage);12+ assert.throws(13+ () => {14+ program.parse(['node', 'test', '--version']);15+ },16+ { code: 'commander.unknownOption' },17+ );18 });19 20 test('when no .version then helpInformation does not include version', () => {21 const program = new commander.Command();22 23 const helpInformation = program.helpInformation();24 24- expect(helpInformation.includes('Usage')).toBe(true);25- expect(helpInformation.includes('version')).toBe(false);25+ assert.equal(helpInformation.includes('Usage'), true);26+ assert.equal(helpInformation.includes('version'), false);27 });28 28- test('when specify default short flag then display version', () => {29+ test('when specify default short flag then display version', (t) => {30 const myVersion = '1.2.3';30- const writeMock = jest.fn();31+ const writeMock = t.mock.fn();32 const program = new commander.Command();33 program34 .exitOverride()35 .configureOutput({ writeOut: writeMock })36 .version(myVersion);37 37- expect(() => {38+ assert.throws(() => {39 program.parse(['node', 'test', '-V']);39- }).toThrow(myVersion);40- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);40+ }, new RegExp(myVersion));41+ const callArgs = writeMock.mock.calls[0].arguments;42+ assert.equal(callArgs[0], `${myVersion}\n`);43 });44 43- test('when specify default long flag then display version', () => {45+ test('when specify default long flag then display version', (t) => {46 const myVersion = '1.2.3';45- const writeMock = jest.fn();47+ const writeMock = t.mock.fn();48 const program = new commander.Command();49 program50 .exitOverride()51 .configureOutput({ writeOut: writeMock })52 .version(myVersion);53 52- expect(() => {54+ assert.throws(() => {55 program.parse(['node', 'test', '--version']);54- }).toThrow(myVersion);55- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);56+ }, new RegExp(myVersion));57+ const callArgs = writeMock.mock.calls[0].arguments;58+ assert.equal(callArgs[0], `${myVersion}\n`);59 });60 61 test('when default .version then helpInformation includes default version help', () => {62 const myVersion = '1.2.3';1 unmodified line64 program.version(myVersion);65 66 const helpInformation = program.helpInformation();67 65- expect(helpInformation.includes('-V, --version')).toBe(true);66- expect(helpInformation.includes('output the version number')).toBe(true);68+ assert.equal(helpInformation.includes('-V, --version'), true);69+ assert.equal(helpInformation.includes('output the version number'), true);70 });71 69- test('when specify custom short flag then display version', () => {72+ test('when specify custom short flag then display version', (t) => {73 const myVersion = '1.2.3';71- const writeMock = jest.fn();74+ const writeMock = t.mock.fn();75 const program = new commander.Command();76 program77 .exitOverride()78 .configureOutput({ writeOut: writeMock })79 .version(myVersion, '-r, --revision');80 78- expect(() => {81+ assert.throws(() => {82 program.parse(['node', 'test', '-r']);80- }).toThrow(myVersion);81- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);83+ }, new RegExp(myVersion));84+ const callArgs = writeMock.mock.calls[0].arguments;85+ assert.equal(callArgs[0], `${myVersion}\n`);86 });87 84- test('when specify just custom short flag then display version', () => {88+ test('when specify just custom short flag then display version', (t) => {89 const myVersion = '1.2.3';86- const writeMock = jest.fn();90+ const writeMock = t.mock.fn();91 const program = new commander.Command();92 program93 .exitOverride()94 .configureOutput({ writeOut: writeMock })95 .version(myVersion, '-r');96 93- expect(() => {97+ assert.throws(() => {98 program.parse(['node', 'test', '-r']);95- }).toThrow(myVersion);96- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);99+ }, new RegExp(myVersion));100+ const callArgs = writeMock.mock.calls[0].arguments;101+ assert.equal(callArgs[0], `${myVersion}\n`);102 });103 99- test('when specify custom long flag then display version', () => {104+ test('when specify custom long flag then display version', (t) => {105 const myVersion = '1.2.3';101- const writeMock = jest.fn();106+ const writeMock = t.mock.fn();107 const program = new commander.Command();108 program109 .exitOverride()110 .configureOutput({ writeOut: writeMock })111 .version(myVersion, '-r, --revision');112 108- expect(() => {113+ assert.throws(() => {114 program.parse(['node', 'test', '--revision']);110- }).toThrow(myVersion);111- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);115+ }, new RegExp(myVersion));116+ const callArgs = writeMock.mock.calls[0].arguments;117+ assert.equal(callArgs[0], `${myVersion}\n`);118 });119 114- test('when specify just custom long flag then display version', () => {120+ test('when specify just custom long flag then display version', (t) => {121 const myVersion = '1.2.3';116- const writeMock = jest.fn();122+ const writeMock = t.mock.fn();123 const program = new commander.Command();124 program125 .exitOverride()126 .configureOutput({ writeOut: writeMock })127 .version(myVersion, '--revision');128 123- expect(() => {129+ assert.throws(() => {130 program.parse(['node', 'test', '--revision']);125- }).toThrow(myVersion);126- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);131+ }, new RegExp(myVersion));132+ const callArgs = writeMock.mock.calls[0].arguments;133+ assert.equal(callArgs[0], `${myVersion}\n`);134 });135 136 test('when custom .version then helpInformation includes custom version help', () => {137 const myVersion = '1.2.3';3 unmodified lines141 program.version(myVersion, myVersionFlags, myVersionDescription);142 143 const helpInformation = program.helpInformation();144 138- expect(helpInformation.includes(myVersionFlags)).toBe(true);139- expect(helpInformation.includes(myVersionDescription)).toBe(true);145+ assert.equal(helpInformation.includes(myVersionFlags), true);146+ assert.equal(helpInformation.includes(myVersionDescription), true);147 });148 142- test('when have .version+version and specify version then command called', () => {143- const actionMock = jest.fn();149+ test('when have .version+version and specify version then command called', (t) => {150+ const actionMock = t.mock.fn();151 const program = new commander.Command();152 program.version('1.2.3').command('version').action(actionMock);153 154 program.parse(['node', 'test', 'version']);155 149- expect(actionMock).toHaveBeenCalled();156+ assert.equal(actionMock.mock.callCount(), 1);157 });158 152- test('when have .version+version and specify --version then version displayed', () => {159+ test('when have .version+version and specify --version then version displayed', (t) => {160 const myVersion = '1.2.3';154- const writeMock = jest.fn();161+ const writeMock = t.mock.fn();162 const program = new commander.Command();163 program164 .exitOverride()165 .configureOutput({ writeOut: writeMock })166 .version(myVersion)167 .command('version')168 .action(() => {});169 163- expect(() => {170+ assert.throws(() => {171 program.parse(['node', 'test', '--version']);165- }).toThrow(myVersion);166- expect(writeMock).toHaveBeenCalledWith(`${myVersion}\n`);172+ }, new RegExp(myVersion));173+ const callArgs = writeMock.mock.calls[0].arguments;174+ assert.equal(callArgs[0], `${myVersion}\n`);175 });176 177 test('when specify version then can get version', () => {178 const myVersion = '1.2.3';179 const program = new commander.Command();180 program.version(myVersion);173- expect(program.version()).toEqual(myVersion);181+ assert.equal(program.version(), myVersion);182 });183 });deleted:tests/program.test.js-68 removed
1-const {2- program,3- Command,4- Option,5- Argument,6- Help,7- CommanderError,8- InvalidArgumentError,9- InvalidOptionArgumentError,10- createCommand,11- createOption,12- createArgument,13-} = require('../index.js');14-15-// Do some testing of the default export(s).16-// Similar tests to ts-imports.test.ts and esm-imports-test.js.17-18-/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "checkClass"] }] */19-20-function checkClass(obj, name) {21- expect(typeof obj).toEqual('object');22- expect(obj.constructor.name).toEqual(name);23-}24-25-test('program', () => {26- checkClass(program, 'Command');27-});28-29-test('Command', () => {30- checkClass(new Command('name'), 'Command');31-});32-33-test('Option', () => {34- checkClass(new Option('-e, --example', 'description'), 'Option');35-});36-37-test('Argument', () => {38- checkClass(new Argument('<foo>', 'description'), 'Argument');39-});40-41-test('Help', () => {42- checkClass(new Help(), 'Help');43-});44-45-test('CommanderError', () => {46- checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');47-});48-49-test('InvalidArgumentError', () => {50- checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');51-});52-53-test('InvalidOptionArgumentError', () => {54- // Deprecated55- checkClass(new InvalidOptionArgumentError('failed'), 'InvalidArgumentError');56-});57-58-test('createCommand', () => {59- checkClass(createCommand('foo'), 'Command');60-});61-62-test('createOption', () => {63- checkClass(createOption('-e, --example', 'description'), 'Option');64-});65-66-test('createArgument', () => {67- checkClass(createArgument('<foo>', 'description'), 'Argument');68-});added:tests/testHelpers.js+23 added
1+const { Command } = require('../');2+3+/**4+ * Create a Command configured for using in tests.5+ *6+ * Throws exceptions instead of calling process.exit (.exitOverride())7+ * and output suppressed.8+ *9+ * @returns Command10+ */11+12+function createTestCommand() {13+ const cmd = new Command();14+ cmd15+ .exitOverride() // So we get exceptions instead of process.exit16+ .configureOutput({17+ writeOut: () => {},18+ writeErr: () => {},19+ });20+ return cmd;21+}22+23+exports.createTestCommand = createTestCommand;deleted:tests/ts-imports.test.ts-53 removed
1-import {2- program,3- Command,4- Option,5- CommanderError,6- InvalidArgumentError,7- InvalidOptionArgumentError,8- Help,9- createCommand,10-} from '../';11-12-// Do some simple checks that expected imports are available at runtime.13-// Similar tests to esm-imports-test.js14-15-/* eslint-disable jest/expect-expect */16-17-function checkClass(obj: object, name: string): void {18- expect(typeof obj).toEqual('object');19- expect(obj.constructor.name).toEqual(name);20-}21-22-test('program', () => {23- checkClass(program, 'Command');24-});25-26-test('createCommand', () => {27- checkClass(createCommand(), 'Command');28-});29-30-test('Command', () => {31- checkClass(new Command('name'), 'Command');32-});33-34-test('Option', () => {35- checkClass(new Option('-e, --example', 'description'), 'Option');36-});37-38-test('CommanderError', () => {39- checkClass(new CommanderError(1, 'code', 'failed'), 'CommanderError');40-});41-42-test('InvalidArgumentError', () => {43- checkClass(new InvalidArgumentError('failed'), 'InvalidArgumentError');44-});45-46-test('InvalidOptionArgumentError', () => {47- // Deprecated48- checkClass(new InvalidOptionArgumentError('failed'), 'InvalidArgumentError');49-});50-51-test('Help', () => {52- checkClass(new Help(), 'Help');53-});modified:tests/useColor.test.js+24 added-17 removed
1 const { useColor } = require('../lib/command.js');2+const { test, describe, beforeEach, after } = require('node:test');3+const assert = require('node:assert/strict');4 5 describe('internal useColor environment variable support', () => {6 let holdNoColor = process.env.NO_COLOR;7 let holdForceColor = process.env.FORCE_COLOR;4 unmodified lines12 delete process.env.FORCE_COLOR;13 delete process.env.CLICOLOR_FORCE;14 });15 14- afterAll(() => {16+ after(() => {17 if (holdNoColor === undefined) delete process.env.NO_COLOR;18 else process.env.NO_COLOR = holdNoColor;19 20 if (holdForceColor === undefined) delete process.env.FORCE_COLOR;3 unmodified lines24 else process.env.CLICOLOR_FORCE = holdCliColorForce;25 });26 27 test('when no ENV defined then returns undefined', () => {26- expect(useColor()).toBeUndefined();28+ assert.equal(useColor(), undefined);29 });30 31 // https://no-color.org32 //1 unmodified line34 // when present and not an empty string (regardless of its value), prevents the addition of ANSI color.35 36 test('when NO_COLOR defined then returns false', () => {37 process.env.NO_COLOR = 'non-empty';36- expect(useColor()).toBe(false);38+ assert.equal(useColor(), false);39 });40 41 test('when NO_COLOR empty then returns undefined', () => {42 process.env.NO_COLOR = '';41- expect(useColor()).toBe(undefined);43+ assert.equal(useColor(), undefined);44 });45 46 // https://bixense.com/clicolors/47 48 test('when CLICOLOR_FORCE defined then returns true', () => {49 process.env.CLICOLOR_FORCE = '1';48- expect(useColor()).toBe(true);50+ assert.equal(useColor(), true);51 });52 53 test('when CLICOLOR_FORCE empty then returns true', () => {54 // Follow original Apple usage and test for existence, don't ignore empty value.55 process.env.CLICOLOR_FORCE = '';54- expect(useColor()).toBe(true);56+ assert.equal(useColor(), true);57 });58 59 test('when CLICOLOR_FORCE and NO_COLOR defined then returns false', () => {60 // NO_COLOR trumps CLICOLOR_FORCE61 process.env.NO_COLOR = '1';62 process.env.CLICOLOR_FORCE = '1';61- expect(useColor()).toBe(false);63+ assert.equal(useColor(), false);64 });65 66 // chalk: https://github.com/chalk/supports-color/blob/c214314a14bcb174b12b3014b2b0a8de375029ae/index.js#L3367 // node: https://github.com/nodejs/node/blob/0a00217a5f67ef4a22384cfc80eb6dd9a917fdc1/lib/internal/tty.js#L1092 unmodified lines70 // Chalk ignores anything except for 0,1,2,3,4,true,false values.71 // Node somewhat follows Chalk with 0,1,2,3,true, but treats empty as true and unexpected values as false.72 // Test the expected Chalk values (which do produce same result in node).73 72- test.each([73- ['true', true],74- ['false', false],75- ['0', false],76- ['1', true],77- ['2', true],78- ['3', true],79- ])('when FORCE_COLOR=%s then returns %s', (value, result) => {80- process.env.FORCE_COLOR = value;81- expect(useColor()).toBe(result);74+ describe('FORCE_COLOR environment variable tests', () => {75+ const testCases = [76+ ['true', true],77+ ['false', false],78+ ['0', false],79+ ['1', true],80+ ['2', true],81+ ['3', true],82+ ];83+ for (const [value, result] of testCases) {84+ test(`when FORCE_COLOR=${value} then returns ${result}`, () => {85+ process.env.FORCE_COLOR = value;86+ assert.equal(useColor(), result);87+ });88+ }89 });90 });modified:eslint.config.js-2 removed
1 const globals = require('globals');2 const esLintjs = require('@eslint/js');3-const jest = require('eslint-plugin-jest');3 const tseslint = require('typescript-eslint');4 const prettier = require('eslint-config-prettier');5 6 // Only run tseslint on the files that we have included for TypeScript.3 unmodified lines10 // Using tseslint.config adds some type safety and `extends` to simplify customising config array.11 module.exports = tseslint.config(12 // Add recommended rules.13 esLintjs.configs.recommended,15- jest.configs['flat/recommended'],14 // tseslint with different setup for js/ts15 {16 files: tsconfigJsFiles,17 extends: [...tseslint.configs.recommended],50 unmodified linesmodified:package-lock.json+7 added-3132 removed
8 unmodified lines9 "version": "14.0.0",10 "license": "MIT",11 "devDependencies": {12 "@eslint/js": "^9.4.0",13- "@types/jest": "^29.2.4",13 "@types/node": "^22.7.4",14 "eslint": "^9.17.0",15 "eslint-config-prettier": "^10.0.1",17- "eslint-plugin-jest": "^28.3.0",16 "globals": "^16.0.0",19- "jest": "^29.3.1",17 "prettier": "^3.2.5",21- "ts-jest": "^29.0.3",18 "tsd": "^0.31.0",19 "typescript": "^5.0.4",20 "typescript-eslint": "^8.12.2"21 },22 "engines": {23 "node": ">=20"24 }25 },30- "node_modules/@ampproject/remapping": {31- "version": "2.3.0",32- "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",33- "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",34- "dev": true,35- "license": "Apache-2.0",36- "dependencies": {37- "@jridgewell/gen-mapping": "^0.3.5",38- "@jridgewell/trace-mapping": "^0.3.24"39- },40- "engines": {41- "node": ">=6.0.0"42- }43- },26 "node_modules/@babel/code-frame": {27 "version": "7.26.2",28 "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz",29 "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",7 unmodified lines37 "engines": {38 "node": ">=6.9.0"39 }40 },59- "node_modules/@babel/compat-data": {60- "version": "7.26.8",61- "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.8.tgz",62- "integrity": "sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ==",63- "dev": true,64- "license": "MIT",65- "engines": {66- "node": ">=6.9.0"67- }68- },69- "node_modules/@babel/core": {70- "version": "7.26.10",71- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.10.tgz",72- "integrity": "sha512-vMqyb7XCDMPvJFFOaT9kxtiRh42GwlZEg1/uIgtZshS5a/8OaduUfCi7kynKgc3Tw/6Uo2D+db9qBttghhmxwQ==",73- "dev": true,74- "license": "MIT",75- "dependencies": {76- "@ampproject/remapping": "^2.2.0",77- "@babel/code-frame": "^7.26.2",78- "@babel/generator": "^7.26.10",79- "@babel/helper-compilation-targets": "^7.26.5",80- "@babel/helper-module-transforms": "^7.26.0",81- "@babel/helpers": "^7.26.10",82- "@babel/parser": "^7.26.10",83- "@babel/template": "^7.26.9",84- "@babel/traverse": "^7.26.10",85- "@babel/types": "^7.26.10",86- "convert-source-map": "^2.0.0",87- "debug": "^4.1.0",88- "gensync": "^1.0.0-beta.2",89- "json5": "^2.2.3",90- "semver": "^6.3.1"91- },92- "engines": {93- "node": ">=6.9.0"94- },95- "funding": {96- "type": "opencollective",97- "url": "https://opencollective.com/babel"98- }99- },100- "node_modules/@babel/core/node_modules/semver": {101- "version": "6.3.1",102- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",103- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",104- "dev": true,105- "license": "ISC",106- "bin": {107- "semver": "bin/semver.js"108- }109- },110- "node_modules/@babel/generator": {111- "version": "7.27.0",112- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.27.0.tgz",113- "integrity": "sha512-VybsKvpiN1gU1sdMZIp7FcqphVVKEwcuj02x73uvcHE0PTihx1nlBcowYWhDwjpoAXRv43+gDzyggGnn1XZhVw==",114- "dev": true,115- "license": "MIT",116- "dependencies": {117- "@babel/parser": "^7.27.0",118- "@babel/types": "^7.27.0",119- "@jridgewell/gen-mapping": "^0.3.5",120- "@jridgewell/trace-mapping": "^0.3.25",121- "jsesc": "^3.0.2"122- },123- "engines": {124- "node": ">=6.9.0"125- }126- },127- "node_modules/@babel/helper-compilation-targets": {128- "version": "7.27.0",129- "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.0.tgz",130- "integrity": "sha512-LVk7fbXml0H2xH34dFzKQ7TDZ2G4/rVTOrq9V+icbbadjbVxxeFeDsNHv2SrZeWoA+6ZiTyWYWtScEIW07EAcA==",131- "dev": true,132- "license": "MIT",133- "dependencies": {134- "@babel/compat-data": "^7.26.8",135- "@babel/helper-validator-option": "^7.25.9",136- "browserslist": "^4.24.0",137- "lru-cache": "^5.1.1",138- "semver": "^6.3.1"139- },140- "engines": {141- "node": ">=6.9.0"142- }143- },144- "node_modules/@babel/helper-compilation-targets/node_modules/semver": {145- "version": "6.3.1",146- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",147- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",148- "dev": true,149- "license": "ISC",150- "bin": {151- "semver": "bin/semver.js"152- }153- },154- "node_modules/@babel/helper-module-imports": {155- "version": "7.25.9",156- "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz",157- "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==",158- "dev": true,159- "license": "MIT",160- "dependencies": {161- "@babel/traverse": "^7.25.9",162- "@babel/types": "^7.25.9"163- },164- "engines": {165- "node": ">=6.9.0"166- }167- },168- "node_modules/@babel/helper-module-transforms": {169- "version": "7.26.0",170- "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz",171- "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==",172- "dev": true,173- "license": "MIT",174- "dependencies": {175- "@babel/helper-module-imports": "^7.25.9",176- "@babel/helper-validator-identifier": "^7.25.9",177- "@babel/traverse": "^7.25.9"178- },179- "engines": {180- "node": ">=6.9.0"181- },182- "peerDependencies": {183- "@babel/core": "^7.0.0"184- }185- },186- "node_modules/@babel/helper-plugin-utils": {187- "version": "7.26.5",188- "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz",189- "integrity": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==",190- "dev": true,191- "license": "MIT",192- "engines": {193- "node": ">=6.9.0"194- }195- },196- "node_modules/@babel/helper-string-parser": {197- "version": "7.25.9",198- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",199- "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",200- "dev": true,201- "license": "MIT",202- "engines": {203- "node": ">=6.9.0"204- }205- },41 "node_modules/@babel/helper-validator-identifier": {42 "version": "7.25.9",43 "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",44 "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",2 unmodified lines47 "engines": {48 "node": ">=6.9.0"49 }50 },216- "node_modules/@babel/helper-validator-option": {217- "version": "7.25.9",218- "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz",219- "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==",220- "dev": true,221- "license": "MIT",222- "engines": {223- "node": ">=6.9.0"224- }225- },226- "node_modules/@babel/helpers": {227- "version": "7.27.0",228- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.0.tgz",229- "integrity": "sha512-U5eyP/CTFPuNE3qk+WZMxFkp/4zUzdceQlfzf7DdGdhp+Fezd7HD+i8Y24ZuTMKX3wQBld449jijbGq6OdGNQg==",230- "dev": true,231- "license": "MIT",232- "dependencies": {233- "@babel/template": "^7.27.0",234- "@babel/types": "^7.27.0"235- },236- "engines": {237- "node": ">=6.9.0"238- }239- },240- "node_modules/@babel/parser": {241- "version": "7.27.0",242- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz",243- "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==",244- "dev": true,245- "license": "MIT",246- "dependencies": {247- "@babel/types": "^7.27.0"248- },249- "bin": {250- "parser": "bin/babel-parser.js"251- },252- "engines": {253- "node": ">=6.0.0"254- }255- },256- "node_modules/@babel/plugin-syntax-async-generators": {257- "version": "7.8.4",258- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz",259- "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==",260- "dev": true,261- "license": "MIT",262- "dependencies": {263- "@babel/helper-plugin-utils": "^7.8.0"264- },265- "peerDependencies": {266- "@babel/core": "^7.0.0-0"267- }268- },269- "node_modules/@babel/plugin-syntax-bigint": {270- "version": "7.8.3",271- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz",272- "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==",273- "dev": true,274- "license": "MIT",275- "dependencies": {276- "@babel/helper-plugin-utils": "^7.8.0"277- },278- "peerDependencies": {279- "@babel/core": "^7.0.0-0"280- }281- },282- "node_modules/@babel/plugin-syntax-class-properties": {283- "version": "7.12.13",284- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz",285- "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==",286- "dev": true,287- "license": "MIT",288- "dependencies": {289- "@babel/helper-plugin-utils": "^7.12.13"290- },291- "peerDependencies": {292- "@babel/core": "^7.0.0-0"293- }294- },295- "node_modules/@babel/plugin-syntax-class-static-block": {296- "version": "7.14.5",297- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz",298- "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==",299- "dev": true,300- "license": "MIT",301- "dependencies": {302- "@babel/helper-plugin-utils": "^7.14.5"303- },304- "engines": {305- "node": ">=6.9.0"306- },307- "peerDependencies": {308- "@babel/core": "^7.0.0-0"309- }310- },311- "node_modules/@babel/plugin-syntax-import-attributes": {312- "version": "7.26.0",313- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.26.0.tgz",314- "integrity": "sha512-e2dttdsJ1ZTpi3B9UYGLw41hifAubg19AtCu/2I/F1QNVclOBr1dYpTdmdyZ84Xiz43BS/tCUkMAZNLv12Pi+A==",315- "dev": true,316- "license": "MIT",317- "dependencies": {318- "@babel/helper-plugin-utils": "^7.25.9"319- },320- "engines": {321- "node": ">=6.9.0"322- },323- "peerDependencies": {324- "@babel/core": "^7.0.0-0"325- }326- },327- "node_modules/@babel/plugin-syntax-import-meta": {328- "version": "7.10.4",329- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz",330- "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==",331- "dev": true,332- "license": "MIT",333- "dependencies": {334- "@babel/helper-plugin-utils": "^7.10.4"335- },336- "peerDependencies": {337- "@babel/core": "^7.0.0-0"338- }339- },340- "node_modules/@babel/plugin-syntax-json-strings": {341- "version": "7.8.3",342- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz",343- "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==",344- "dev": true,345- "license": "MIT",346- "dependencies": {347- "@babel/helper-plugin-utils": "^7.8.0"348- },349- "peerDependencies": {350- "@babel/core": "^7.0.0-0"351- }352- },353- "node_modules/@babel/plugin-syntax-jsx": {354- "version": "7.25.9",355- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz",356- "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==",357- "dev": true,358- "license": "MIT",359- "dependencies": {360- "@babel/helper-plugin-utils": "^7.25.9"361- },362- "engines": {363- "node": ">=6.9.0"364- },365- "peerDependencies": {366- "@babel/core": "^7.0.0-0"367- }368- },369- "node_modules/@babel/plugin-syntax-logical-assignment-operators": {370- "version": "7.10.4",371- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz",372- "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==",373- "dev": true,374- "license": "MIT",375- "dependencies": {376- "@babel/helper-plugin-utils": "^7.10.4"377- },378- "peerDependencies": {379- "@babel/core": "^7.0.0-0"380- }381- },382- "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": {383- "version": "7.8.3",384- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz",385- "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==",386- "dev": true,387- "license": "MIT",388- "dependencies": {389- "@babel/helper-plugin-utils": "^7.8.0"390- },391- "peerDependencies": {392- "@babel/core": "^7.0.0-0"393- }394- },395- "node_modules/@babel/plugin-syntax-numeric-separator": {396- "version": "7.10.4",397- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz",398- "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==",399- "dev": true,400- "license": "MIT",401- "dependencies": {402- "@babel/helper-plugin-utils": "^7.10.4"403- },404- "peerDependencies": {405- "@babel/core": "^7.0.0-0"406- }407- },408- "node_modules/@babel/plugin-syntax-object-rest-spread": {409- "version": "7.8.3",410- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz",411- "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==",412- "dev": true,413- "license": "MIT",414- "dependencies": {415- "@babel/helper-plugin-utils": "^7.8.0"416- },417- "peerDependencies": {418- "@babel/core": "^7.0.0-0"419- }420- },421- "node_modules/@babel/plugin-syntax-optional-catch-binding": {422- "version": "7.8.3",423- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz",424- "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==",425- "dev": true,426- "license": "MIT",427- "dependencies": {428- "@babel/helper-plugin-utils": "^7.8.0"429- },430- "peerDependencies": {431- "@babel/core": "^7.0.0-0"432- }433- },434- "node_modules/@babel/plugin-syntax-optional-chaining": {435- "version": "7.8.3",436- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz",437- "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==",438- "dev": true,439- "license": "MIT",440- "dependencies": {441- "@babel/helper-plugin-utils": "^7.8.0"442- },443- "peerDependencies": {444- "@babel/core": "^7.0.0-0"445- }446- },447- "node_modules/@babel/plugin-syntax-private-property-in-object": {448- "version": "7.14.5",449- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz",450- "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==",451- "dev": true,452- "license": "MIT",453- "dependencies": {454- "@babel/helper-plugin-utils": "^7.14.5"455- },456- "engines": {457- "node": ">=6.9.0"458- },459- "peerDependencies": {460- "@babel/core": "^7.0.0-0"461- }462- },463- "node_modules/@babel/plugin-syntax-top-level-await": {464- "version": "7.14.5",465- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz",466- "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==",467- "dev": true,468- "license": "MIT",469- "dependencies": {470- "@babel/helper-plugin-utils": "^7.14.5"471- },472- "engines": {473- "node": ">=6.9.0"474- },475- "peerDependencies": {476- "@babel/core": "^7.0.0-0"477- }478- },479- "node_modules/@babel/plugin-syntax-typescript": {480- "version": "7.25.9",481- "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz",482- "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==",483- "dev": true,484- "license": "MIT",485- "dependencies": {486- "@babel/helper-plugin-utils": "^7.25.9"487- },488- "engines": {489- "node": ">=6.9.0"490- },491- "peerDependencies": {492- "@babel/core": "^7.0.0-0"493- }494- },495- "node_modules/@babel/template": {496- "version": "7.27.0",497- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.0.tgz",498- "integrity": "sha512-2ncevenBqXI6qRMukPlXwHKHchC7RyMuu4xv5JBXRfOGVcTy1mXCD12qrp7Jsoxll1EV3+9sE4GugBVRjT2jFA==",499- "dev": true,500- "license": "MIT",501- "dependencies": {502- "@babel/code-frame": "^7.26.2",503- "@babel/parser": "^7.27.0",504- "@babel/types": "^7.27.0"505- },506- "engines": {507- "node": ">=6.9.0"508- }509- },510- "node_modules/@babel/traverse": {511- "version": "7.27.0",512- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.27.0.tgz",513- "integrity": "sha512-19lYZFzYVQkkHkl4Cy4WrAVcqBkgvV2YM2TU3xG6DIwO7O3ecbDPfW3yM3bjAGcqcQHi+CCtjMR3dIEHxsd6bA==",514- "dev": true,515- "license": "MIT",516- "dependencies": {517- "@babel/code-frame": "^7.26.2",518- "@babel/generator": "^7.27.0",519- "@babel/parser": "^7.27.0",520- "@babel/template": "^7.27.0",521- "@babel/types": "^7.27.0",522- "debug": "^4.3.1",523- "globals": "^11.1.0"524- },525- "engines": {526- "node": ">=6.9.0"527- }528- },529- "node_modules/@babel/traverse/node_modules/globals": {530- "version": "11.12.0",531- "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",532- "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",533- "dev": true,534- "license": "MIT",535- "engines": {536- "node": ">=4"537- }538- },539- "node_modules/@babel/types": {540- "version": "7.27.0",541- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz",542- "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==",543- "dev": true,544- "license": "MIT",545- "dependencies": {546- "@babel/helper-string-parser": "^7.25.9",547- "@babel/helper-validator-identifier": "^7.25.9"548- },549- "engines": {550- "node": ">=6.9.0"551- }552- },553- "node_modules/@bcoe/v8-coverage": {554- "version": "0.2.3",555- "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",556- "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",557- "dev": true,558- "license": "MIT"559- },51 "node_modules/@eslint-community/eslint-utils": {52 "version": "4.5.1",53 "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.5.1.tgz",54 "integrity": "sha512-soEIOALTfTK6EjmKMMoLugwaP0rzkad90iIWd1hMO9ARkSAyjfMfkRRhLvD5qH7vvM0Cg72pieUfR6yh6XxC4w==",209 unmodified lines264 "type": "github",265 "url": "https://github.com/sponsors/nzakas"266 }267 },777- "node_modules/@istanbuljs/load-nyc-config": {778- "version": "1.1.0",779- "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",780- "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==",781- "dev": true,782- "license": "ISC",783- "dependencies": {784- "camelcase": "^5.3.1",785- "find-up": "^4.1.0",786- "get-package-type": "^0.1.0",787- "js-yaml": "^3.13.1",788- "resolve-from": "^5.0.0"789- },790- "engines": {791- "node": ">=8"792- }793- },794- "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": {795- "version": "1.0.10",796- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",797- "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",798- "dev": true,799- "license": "MIT",800- "dependencies": {801- "sprintf-js": "~1.0.2"802- }803- },804- "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": {805- "version": "4.1.0",806- "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",807- "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",808- "dev": true,809- "license": "MIT",810- "dependencies": {811- "locate-path": "^5.0.0",812- "path-exists": "^4.0.0"813- },814- "engines": {815- "node": ">=8"816- }817- },818- "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": {819- "version": "3.14.1",820- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",821- "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",822- "dev": true,823- "license": "MIT",824- "dependencies": {825- "argparse": "^1.0.7",826- "esprima": "^4.0.0"827- },828- "bin": {829- "js-yaml": "bin/js-yaml.js"830- }831- },832- "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": {833- "version": "5.0.0",834- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",835- "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",836- "dev": true,837- "license": "MIT",838- "dependencies": {839- "p-locate": "^4.1.0"840- },841- "engines": {842- "node": ">=8"843- }844- },845- "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": {846- "version": "2.3.0",847- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",848- "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",849- "dev": true,850- "license": "MIT",851- "dependencies": {852- "p-try": "^2.0.0"853- },854- "engines": {855- "node": ">=6"856- },857- "funding": {858- "url": "https://github.com/sponsors/sindresorhus"859- }860- },861- "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": {862- "version": "4.1.0",863- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",864- "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",865- "dev": true,866- "license": "MIT",867- "dependencies": {868- "p-limit": "^2.2.0"869- },870- "engines": {871- "node": ">=8"872- }873- },874- "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": {875- "version": "5.0.0",876- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",877- "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",878- "dev": true,879- "license": "MIT",880- "engines": {881- "node": ">=8"882- }883- },884- "node_modules/@istanbuljs/schema": {885- "version": "0.1.3",886- "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz",887- "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==",888- "dev": true,889- "license": "MIT",890- "engines": {891- "node": ">=8"892- }893- },894- "node_modules/@jest/console": {895- "version": "29.7.0",896- "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz",897- "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==",898- "dev": true,899- "license": "MIT",900- "dependencies": {901- "@jest/types": "^29.6.3",902- "@types/node": "*",903- "chalk": "^4.0.0",904- "jest-message-util": "^29.7.0",905- "jest-util": "^29.7.0",906- "slash": "^3.0.0"907- },908- "engines": {909- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"910- }911- },912- "node_modules/@jest/core": {913- "version": "29.7.0",914- "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz",915- "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==",916- "dev": true,917- "license": "MIT",918- "dependencies": {919- "@jest/console": "^29.7.0",920- "@jest/reporters": "^29.7.0",921- "@jest/test-result": "^29.7.0",922- "@jest/transform": "^29.7.0",923- "@jest/types": "^29.6.3",924- "@types/node": "*",925- "ansi-escapes": "^4.2.1",926- "chalk": "^4.0.0",927- "ci-info": "^3.2.0",928- "exit": "^0.1.2",929- "graceful-fs": "^4.2.9",930- "jest-changed-files": "^29.7.0",931- "jest-config": "^29.7.0",932- "jest-haste-map": "^29.7.0",933- "jest-message-util": "^29.7.0",934- "jest-regex-util": "^29.6.3",935- "jest-resolve": "^29.7.0",936- "jest-resolve-dependencies": "^29.7.0",937- "jest-runner": "^29.7.0",938- "jest-runtime": "^29.7.0",939- "jest-snapshot": "^29.7.0",940- "jest-util": "^29.7.0",941- "jest-validate": "^29.7.0",942- "jest-watcher": "^29.7.0",943- "micromatch": "^4.0.4",944- "pretty-format": "^29.7.0",945- "slash": "^3.0.0",946- "strip-ansi": "^6.0.0"947- },948- "engines": {949- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"950- },951- "peerDependencies": {952- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"953- },954- "peerDependenciesMeta": {955- "node-notifier": {956- "optional": true957- }958- }959- },960- "node_modules/@jest/environment": {961- "version": "29.7.0",962- "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz",963- "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==",964- "dev": true,965- "license": "MIT",966- "dependencies": {967- "@jest/fake-timers": "^29.7.0",968- "@jest/types": "^29.6.3",969- "@types/node": "*",970- "jest-mock": "^29.7.0"971- },972- "engines": {973- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"974- }975- },976- "node_modules/@jest/expect": {977- "version": "29.7.0",978- "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz",979- "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==",980- "dev": true,981- "license": "MIT",982- "dependencies": {983- "expect": "^29.7.0",984- "jest-snapshot": "^29.7.0"985- },986- "engines": {987- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"988- }989- },990- "node_modules/@jest/expect-utils": {991- "version": "29.7.0",992- "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz",993- "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==",994- "dev": true,995- "license": "MIT",996- "dependencies": {997- "jest-get-type": "^29.6.3"998- },999- "engines": {1000- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1001- }1002- },1003- "node_modules/@jest/fake-timers": {1004- "version": "29.7.0",1005- "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz",1006- "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==",1007- "dev": true,1008- "license": "MIT",1009- "dependencies": {1010- "@jest/types": "^29.6.3",1011- "@sinonjs/fake-timers": "^10.0.2",1012- "@types/node": "*",1013- "jest-message-util": "^29.7.0",1014- "jest-mock": "^29.7.0",1015- "jest-util": "^29.7.0"1016- },1017- "engines": {1018- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1019- }1020- },1021- "node_modules/@jest/globals": {1022- "version": "29.7.0",1023- "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz",1024- "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==",1025- "dev": true,1026- "license": "MIT",1027- "dependencies": {1028- "@jest/environment": "^29.7.0",1029- "@jest/expect": "^29.7.0",1030- "@jest/types": "^29.6.3",1031- "jest-mock": "^29.7.0"1032- },1033- "engines": {1034- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1035- }1036- },1037- "node_modules/@jest/reporters": {1038- "version": "29.7.0",1039- "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz",1040- "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==",1041- "dev": true,1042- "license": "MIT",1043- "dependencies": {1044- "@bcoe/v8-coverage": "^0.2.3",1045- "@jest/console": "^29.7.0",1046- "@jest/test-result": "^29.7.0",1047- "@jest/transform": "^29.7.0",1048- "@jest/types": "^29.6.3",1049- "@jridgewell/trace-mapping": "^0.3.18",1050- "@types/node": "*",1051- "chalk": "^4.0.0",1052- "collect-v8-coverage": "^1.0.0",1053- "exit": "^0.1.2",1054- "glob": "^7.1.3",1055- "graceful-fs": "^4.2.9",1056- "istanbul-lib-coverage": "^3.0.0",1057- "istanbul-lib-instrument": "^6.0.0",1058- "istanbul-lib-report": "^3.0.0",1059- "istanbul-lib-source-maps": "^4.0.0",1060- "istanbul-reports": "^3.1.3",1061- "jest-message-util": "^29.7.0",1062- "jest-util": "^29.7.0",1063- "jest-worker": "^29.7.0",1064- "slash": "^3.0.0",1065- "string-length": "^4.0.1",1066- "strip-ansi": "^6.0.0",1067- "v8-to-istanbul": "^9.0.1"1068- },1069- "engines": {1070- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1071- },1072- "peerDependencies": {1073- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"1074- },1075- "peerDependenciesMeta": {1076- "node-notifier": {1077- "optional": true1078- }1079- }1080- },268 "node_modules/@jest/schemas": {269 "version": "29.6.3",270 "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz",271 "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==",5 unmodified lines277 "engines": {278 "node": "^14.15.0 || ^16.10.0 || >=18.0.0"279 }280 },1094- "node_modules/@jest/source-map": {1095- "version": "29.6.3",1096- "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz",1097- "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==",1098- "dev": true,1099- "license": "MIT",1100- "dependencies": {1101- "@jridgewell/trace-mapping": "^0.3.18",1102- "callsites": "^3.0.0",1103- "graceful-fs": "^4.2.9"1104- },1105- "engines": {1106- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1107- }1108- },1109- "node_modules/@jest/test-result": {1110- "version": "29.7.0",1111- "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz",1112- "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==",1113- "dev": true,1114- "license": "MIT",1115- "dependencies": {1116- "@jest/console": "^29.7.0",1117- "@jest/types": "^29.6.3",1118- "@types/istanbul-lib-coverage": "^2.0.0",1119- "collect-v8-coverage": "^1.0.0"1120- },1121- "engines": {1122- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1123- }1124- },1125- "node_modules/@jest/test-sequencer": {1126- "version": "29.7.0",1127- "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz",1128- "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==",1129- "dev": true,1130- "license": "MIT",1131- "dependencies": {1132- "@jest/test-result": "^29.7.0",1133- "graceful-fs": "^4.2.9",1134- "jest-haste-map": "^29.7.0",1135- "slash": "^3.0.0"1136- },1137- "engines": {1138- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1139- }1140- },1141- "node_modules/@jest/transform": {1142- "version": "29.7.0",1143- "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz",1144- "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==",1145- "dev": true,1146- "license": "MIT",1147- "dependencies": {1148- "@babel/core": "^7.11.6",1149- "@jest/types": "^29.6.3",1150- "@jridgewell/trace-mapping": "^0.3.18",1151- "babel-plugin-istanbul": "^6.1.1",1152- "chalk": "^4.0.0",1153- "convert-source-map": "^2.0.0",1154- "fast-json-stable-stringify": "^2.1.0",1155- "graceful-fs": "^4.2.9",1156- "jest-haste-map": "^29.7.0",1157- "jest-regex-util": "^29.6.3",1158- "jest-util": "^29.7.0",1159- "micromatch": "^4.0.4",1160- "pirates": "^4.0.4",1161- "slash": "^3.0.0",1162- "write-file-atomic": "^4.0.2"1163- },1164- "engines": {1165- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1166- }1167- },1168- "node_modules/@jest/types": {1169- "version": "29.6.3",1170- "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz",1171- "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==",1172- "dev": true,1173- "license": "MIT",1174- "dependencies": {1175- "@jest/schemas": "^29.6.3",1176- "@types/istanbul-lib-coverage": "^2.0.0",1177- "@types/istanbul-reports": "^3.0.0",1178- "@types/node": "*",1179- "@types/yargs": "^17.0.8",1180- "chalk": "^4.0.0"1181- },1182- "engines": {1183- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1184- }1185- },1186- "node_modules/@jridgewell/gen-mapping": {1187- "version": "0.3.8",1188- "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz",1189- "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==",1190- "dev": true,1191- "license": "MIT",1192- "dependencies": {1193- "@jridgewell/set-array": "^1.2.1",1194- "@jridgewell/sourcemap-codec": "^1.4.10",1195- "@jridgewell/trace-mapping": "^0.3.24"1196- },1197- "engines": {1198- "node": ">=6.0.0"1199- }1200- },1201- "node_modules/@jridgewell/resolve-uri": {1202- "version": "3.1.2",1203- "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",1204- "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",1205- "dev": true,1206- "license": "MIT",1207- "engines": {1208- "node": ">=6.0.0"1209- }1210- },1211- "node_modules/@jridgewell/set-array": {1212- "version": "1.2.1",1213- "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",1214- "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",1215- "dev": true,1216- "license": "MIT",1217- "engines": {1218- "node": ">=6.0.0"1219- }1220- },1221- "node_modules/@jridgewell/sourcemap-codec": {1222- "version": "1.5.0",1223- "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",1224- "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",1225- "dev": true,1226- "license": "MIT"1227- },1228- "node_modules/@jridgewell/trace-mapping": {1229- "version": "0.3.25",1230- "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",1231- "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",1232- "dev": true,1233- "license": "MIT",1234- "dependencies": {1235- "@jridgewell/resolve-uri": "^3.1.0",1236- "@jridgewell/sourcemap-codec": "^1.4.14"1237- }1238- },281 "node_modules/@nodelib/fs.scandir": {282 "version": "2.1.5",283 "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",284 "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",37 unmodified lines322 "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==",323 "dev": true,324 "license": "MIT"325 },1284- "node_modules/@sinonjs/commons": {1285- "version": "3.0.1",1286- "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz",1287- "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==",1288- "dev": true,1289- "license": "BSD-3-Clause",1290- "dependencies": {1291- "type-detect": "4.0.8"1292- }1293- },1294- "node_modules/@sinonjs/fake-timers": {1295- "version": "10.3.0",1296- "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz",1297- "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==",1298- "dev": true,1299- "license": "BSD-3-Clause",1300- "dependencies": {1301- "@sinonjs/commons": "^3.0.0"1302- }1303- },326 "node_modules/@tsd/typescript": {327 "version": "5.4.5",328 "resolved": "https://registry.npmjs.org/@tsd/typescript/-/typescript-5.4.5.tgz",329 "integrity": "sha512-saiCxzHRhUrRxQV2JhH580aQUZiKQUXI38FcAcikcfOomAil4G4lxT0RfrrKywoAYP/rqAdYXYmNRLppcd+hQQ==",2 unmodified lines332 "engines": {333 "node": ">=14.17"334 }335 },1314- "node_modules/@types/babel__core": {1315- "version": "7.20.5",1316- "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",1317- "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==",1318- "dev": true,1319- "license": "MIT",1320- "dependencies": {1321- "@babel/parser": "^7.20.7",1322- "@babel/types": "^7.20.7",1323- "@types/babel__generator": "*",1324- "@types/babel__template": "*",1325- "@types/babel__traverse": "*"1326- }1327- },1328- "node_modules/@types/babel__generator": {1329- "version": "7.6.8",1330- "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz",1331- "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==",1332- "dev": true,1333- "license": "MIT",1334- "dependencies": {1335- "@babel/types": "^7.0.0"1336- }1337- },1338- "node_modules/@types/babel__template": {1339- "version": "7.4.4",1340- "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz",1341- "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==",1342- "dev": true,1343- "license": "MIT",1344- "dependencies": {1345- "@babel/parser": "^7.1.0",1346- "@babel/types": "^7.0.0"1347- }1348- },1349- "node_modules/@types/babel__traverse": {1350- "version": "7.20.6",1351- "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz",1352- "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==",1353- "dev": true,1354- "license": "MIT",1355- "dependencies": {1356- "@babel/types": "^7.20.7"1357- }1358- },336 "node_modules/@types/eslint": {337 "version": "7.29.0",338 "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.29.0.tgz",339 "integrity": "sha512-VNcvioYDH8/FxaeTKkM4/TiTwt6pBV9E3OfGmvaw8tPl0rrHCJ4Ll15HRT+pMiFAf/MLQvAzC+6RzUMEL9Ceng==",10 unmodified lines350 "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==",351 "dev": true,352 "license": "MIT"353 },1377- "node_modules/@types/graceful-fs": {1378- "version": "4.1.9",1379- "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz",1380- "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==",1381- "dev": true,1382- "license": "MIT",1383- "dependencies": {1384- "@types/node": "*"1385- }1386- },1387- "node_modules/@types/istanbul-lib-coverage": {1388- "version": "2.0.6",1389- "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",1390- "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",1391- "dev": true,1392- "license": "MIT"1393- },1394- "node_modules/@types/istanbul-lib-report": {1395- "version": "3.0.3",1396- "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz",1397- "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==",1398- "dev": true,1399- "license": "MIT",1400- "dependencies": {1401- "@types/istanbul-lib-coverage": "*"1402- }1403- },1404- "node_modules/@types/istanbul-reports": {1405- "version": "3.0.4",1406- "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz",1407- "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==",1408- "dev": true,1409- "license": "MIT",1410- "dependencies": {1411- "@types/istanbul-lib-report": "*"1412- }1413- },1414- "node_modules/@types/jest": {1415- "version": "29.5.14",1416- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz",1417- "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==",1418- "dev": true,1419- "license": "MIT",1420- "dependencies": {1421- "expect": "^29.0.0",1422- "pretty-format": "^29.0.0"1423- }1424- },354 "node_modules/@types/json-schema": {355 "version": "7.0.15",356 "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",357 "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",23 unmodified lines381 "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==",382 "dev": true,383 "license": "MIT"384 },1456- "node_modules/@types/stack-utils": {1457- "version": "2.0.3",1458- "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz",1459- "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==",1460- "dev": true,1461- "license": "MIT"1462- },1463- "node_modules/@types/yargs": {1464- "version": "17.0.33",1465- "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz",1466- "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==",1467- "dev": true,1468- "license": "MIT",1469- "dependencies": {1470- "@types/yargs-parser": "*"1471- }1472- },1473- "node_modules/@types/yargs-parser": {1474- "version": "21.0.3",1475- "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz",1476- "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==",1477- "dev": true,1478- "license": "MIT"1479- },385 "node_modules/@typescript-eslint/eslint-plugin": {386 "version": "8.29.0",387 "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.29.0.tgz",388 "integrity": "sha512-PAIpk/U7NIS6H7TEtN45SPGLQaHNgB7wSjsQV/8+KYokAb2T/gloOA/Bee2yd4/yKVhPKe5LlaUGhAZk5zmSaQ==",28 unmodified lines417 "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.29.0.tgz",418 "integrity": "sha512-8C0+jlNJOwQso2GapCVWWfW/rzaq7Lbme+vGUFKE31djwNncIpgXD7Cd4weEsDdkoZDjH0lwwr3QDQFuyrMg9g==",419 "dev": true,420 "license": "MIT",421+ "peer": true,422 "dependencies": {423 "@typescript-eslint/scope-manager": "8.29.0",424 "@typescript-eslint/types": "8.29.0",425 "@typescript-eslint/typescript-estree": "8.29.0",168 unmodified lines594 "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz",595 "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==",596 "dev": true,597 "license": "MIT",598+ "peer": true,599 "bin": {600 "acorn": "bin/acorn"601 },602 "engines": {68 unmodified lines671 "funding": {672 "url": "https://github.com/chalk/ansi-styles?sponsor=1"673 }674 },1768- "node_modules/anymatch": {1769- "version": "3.1.3",1770- "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",1771- "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",1772- "dev": true,1773- "license": "ISC",1774- "dependencies": {1775- "normalize-path": "^3.0.0",1776- "picomatch": "^2.0.4"1777- },1778- "engines": {1779- "node": ">= 8"1780- }1781- },675 "node_modules/argparse": {676 "version": "2.0.1",677 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",678 "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",19 unmodified lines698 "engines": {699 "node": ">=0.10.0"700 }701 },1809- "node_modules/async": {1810- "version": "3.2.6",1811- "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",1812- "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",1813- "dev": true,1814- "license": "MIT"1815- },1816- "node_modules/babel-jest": {1817- "version": "29.7.0",1818- "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz",1819- "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==",1820- "dev": true,1821- "license": "MIT",1822- "dependencies": {1823- "@jest/transform": "^29.7.0",1824- "@types/babel__core": "^7.1.14",1825- "babel-plugin-istanbul": "^6.1.1",1826- "babel-preset-jest": "^29.6.3",1827- "chalk": "^4.0.0",1828- "graceful-fs": "^4.2.9",1829- "slash": "^3.0.0"1830- },1831- "engines": {1832- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1833- },1834- "peerDependencies": {1835- "@babel/core": "^7.8.0"1836- }1837- },1838- "node_modules/babel-plugin-istanbul": {1839- "version": "6.1.1",1840- "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz",1841- "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==",1842- "dev": true,1843- "license": "BSD-3-Clause",1844- "dependencies": {1845- "@babel/helper-plugin-utils": "^7.0.0",1846- "@istanbuljs/load-nyc-config": "^1.0.0",1847- "@istanbuljs/schema": "^0.1.2",1848- "istanbul-lib-instrument": "^5.0.4",1849- "test-exclude": "^6.0.0"1850- },1851- "engines": {1852- "node": ">=8"1853- }1854- },1855- "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": {1856- "version": "5.2.1",1857- "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz",1858- "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==",1859- "dev": true,1860- "license": "BSD-3-Clause",1861- "dependencies": {1862- "@babel/core": "^7.12.3",1863- "@babel/parser": "^7.14.7",1864- "@istanbuljs/schema": "^0.1.2",1865- "istanbul-lib-coverage": "^3.2.0",1866- "semver": "^6.3.0"1867- },1868- "engines": {1869- "node": ">=8"1870- }1871- },1872- "node_modules/babel-plugin-istanbul/node_modules/semver": {1873- "version": "6.3.1",1874- "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",1875- "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",1876- "dev": true,1877- "license": "ISC",1878- "bin": {1879- "semver": "bin/semver.js"1880- }1881- },1882- "node_modules/babel-plugin-jest-hoist": {1883- "version": "29.6.3",1884- "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz",1885- "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==",1886- "dev": true,1887- "license": "MIT",1888- "dependencies": {1889- "@babel/template": "^7.3.3",1890- "@babel/types": "^7.3.3",1891- "@types/babel__core": "^7.1.14",1892- "@types/babel__traverse": "^7.0.6"1893- },1894- "engines": {1895- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1896- }1897- },1898- "node_modules/babel-preset-current-node-syntax": {1899- "version": "1.1.0",1900- "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz",1901- "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==",1902- "dev": true,1903- "license": "MIT",1904- "dependencies": {1905- "@babel/plugin-syntax-async-generators": "^7.8.4",1906- "@babel/plugin-syntax-bigint": "^7.8.3",1907- "@babel/plugin-syntax-class-properties": "^7.12.13",1908- "@babel/plugin-syntax-class-static-block": "^7.14.5",1909- "@babel/plugin-syntax-import-attributes": "^7.24.7",1910- "@babel/plugin-syntax-import-meta": "^7.10.4",1911- "@babel/plugin-syntax-json-strings": "^7.8.3",1912- "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",1913- "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",1914- "@babel/plugin-syntax-numeric-separator": "^7.10.4",1915- "@babel/plugin-syntax-object-rest-spread": "^7.8.3",1916- "@babel/plugin-syntax-optional-catch-binding": "^7.8.3",1917- "@babel/plugin-syntax-optional-chaining": "^7.8.3",1918- "@babel/plugin-syntax-private-property-in-object": "^7.14.5",1919- "@babel/plugin-syntax-top-level-await": "^7.14.5"1920- },1921- "peerDependencies": {1922- "@babel/core": "^7.0.0"1923- }1924- },1925- "node_modules/babel-preset-jest": {1926- "version": "29.6.3",1927- "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz",1928- "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==",1929- "dev": true,1930- "license": "MIT",1931- "dependencies": {1932- "babel-plugin-jest-hoist": "^29.6.3",1933- "babel-preset-current-node-syntax": "^1.0.0"1934- },1935- "engines": {1936- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1937- },1938- "peerDependencies": {1939- "@babel/core": "^7.0.0"1940- }1941- },702 "node_modules/balanced-match": {703 "version": "1.0.2",704 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",705 "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",23 unmodified lines729 "engines": {730 "node": ">=8"731 }732 },1973- "node_modules/browserslist": {1974- "version": "4.24.4",1975- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz",1976- "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==",1977- "dev": true,1978- "funding": [1979- {1980- "type": "opencollective",1981- "url": "https://opencollective.com/browserslist"1982- },1983- {1984- "type": "tidelift",1985- "url": "https://tidelift.com/funding/github/npm/browserslist"1986- },1987- {1988- "type": "github",1989- "url": "https://github.com/sponsors/ai"1990- }1991- ],1992- "license": "MIT",1993- "dependencies": {1994- "caniuse-lite": "^1.0.30001688",1995- "electron-to-chromium": "^1.5.73",1996- "node-releases": "^2.0.19",1997- "update-browserslist-db": "^1.1.1"1998- },1999- "bin": {2000- "browserslist": "cli.js"2001- },2002- "engines": {2003- "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"2004- }2005- },2006- "node_modules/bs-logger": {2007- "version": "0.2.6",2008- "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz",2009- "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==",2010- "dev": true,2011- "license": "MIT",2012- "dependencies": {2013- "fast-json-stable-stringify": "2.x"2014- },2015- "engines": {2016- "node": ">= 6"2017- }2018- },2019- "node_modules/bser": {2020- "version": "2.1.1",2021- "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz",2022- "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==",2023- "dev": true,2024- "license": "Apache-2.0",2025- "dependencies": {2026- "node-int64": "^0.4.0"2027- }2028- },2029- "node_modules/buffer-from": {2030- "version": "1.1.2",2031- "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",2032- "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",2033- "dev": true,2034- "license": "MIT"2035- },733 "node_modules/callsites": {734 "version": "3.1.0",735 "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",736 "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",30 unmodified lines767 "funding": {768 "url": "https://github.com/sponsors/sindresorhus"769 }770 },2074- "node_modules/caniuse-lite": {2075- "version": "1.0.30001707",2076- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001707.tgz",2077- "integrity": "sha512-3qtRjw/HQSMlDWf+X79N206fepf4SOOU6SQLMaq/0KkZLmSjPxAkBOQQ+FxbHKfHmYLZFfdWsO3KA90ceHPSnw==",2078- "dev": true,2079- "funding": [2080- {2081- "type": "opencollective",2082- "url": "https://opencollective.com/browserslist"2083- },2084- {2085- "type": "tidelift",2086- "url": "https://tidelift.com/funding/github/npm/caniuse-lite"2087- },2088- {2089- "type": "github",2090- "url": "https://github.com/sponsors/ai"2091- }2092- ],2093- "license": "CC-BY-4.0"2094- },771 "node_modules/chalk": {772 "version": "4.1.2",773 "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",774 "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",9 unmodified lines784 "funding": {785 "url": "https://github.com/chalk/chalk?sponsor=1"786 }787 },2112- "node_modules/char-regex": {2113- "version": "1.0.2",2114- "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz",2115- "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==",2116- "dev": true,2117- "license": "MIT",2118- "engines": {2119- "node": ">=10"2120- }2121- },2122- "node_modules/ci-info": {2123- "version": "3.9.0",2124- "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",2125- "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",2126- "dev": true,2127- "funding": [2128- {2129- "type": "github",2130- "url": "https://github.com/sponsors/sibiraj-s"2131- }2132- ],2133- "license": "MIT",2134- "engines": {2135- "node": ">=8"2136- }2137- },2138- "node_modules/cjs-module-lexer": {2139- "version": "1.4.3",2140- "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz",2141- "integrity": "sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==",2142- "dev": true,2143- "license": "MIT"2144- },2145- "node_modules/cliui": {2146- "version": "8.0.1",2147- "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",2148- "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",2149- "dev": true,2150- "license": "ISC",2151- "dependencies": {2152- "string-width": "^4.2.0",2153- "strip-ansi": "^6.0.1",2154- "wrap-ansi": "^7.0.0"2155- },2156- "engines": {2157- "node": ">=12"2158- }2159- },2160- "node_modules/co": {2161- "version": "4.6.0",2162- "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",2163- "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==",2164- "dev": true,2165- "license": "MIT",2166- "engines": {2167- "iojs": ">= 1.0.0",2168- "node": ">= 0.12.0"2169- }2170- },2171- "node_modules/collect-v8-coverage": {2172- "version": "1.0.2",2173- "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz",2174- "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==",2175- "dev": true,2176- "license": "MIT"2177- },788 "node_modules/color-convert": {789 "version": "2.0.1",790 "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",791 "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",19 unmodified lines811 "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",812 "dev": true,813 "license": "MIT"814 },2205- "node_modules/convert-source-map": {2206- "version": "2.0.0",2207- "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",2208- "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",2209- "dev": true,2210- "license": "MIT"2211- },2212- "node_modules/create-jest": {2213- "version": "29.7.0",2214- "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz",2215- "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==",2216- "dev": true,2217- "license": "MIT",2218- "dependencies": {2219- "@jest/types": "^29.6.3",2220- "chalk": "^4.0.0",2221- "exit": "^0.1.2",2222- "graceful-fs": "^4.2.9",2223- "jest-config": "^29.7.0",2224- "jest-util": "^29.7.0",2225- "prompts": "^2.0.1"2226- },2227- "bin": {2228- "create-jest": "bin/create-jest.js"2229- },2230- "engines": {2231- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"2232- }2233- },815 "node_modules/cross-spawn": {816 "version": "7.0.6",817 "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",818 "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",62 unmodified lines881 "engines": {882 "node": ">=0.10.0"883 }884 },2304- "node_modules/dedent": {2305- "version": "1.5.3",2306- "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz",2307- "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==",2308- "dev": true,2309- "license": "MIT",2310- "peerDependencies": {2311- "babel-plugin-macros": "^3.1.0"2312- },2313- "peerDependenciesMeta": {2314- "babel-plugin-macros": {2315- "optional": true2316- }2317- }2318- },885 "node_modules/deep-is": {886 "version": "0.1.4",887 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",888 "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",889 "dev": true,890 "license": "MIT"891 },2326- "node_modules/deepmerge": {2327- "version": "4.3.1",2328- "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",2329- "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",2330- "dev": true,2331- "license": "MIT",2332- "engines": {2333- "node": ">=0.10.0"2334- }2335- },2336- "node_modules/detect-newline": {2337- "version": "3.1.0",2338- "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz",2339- "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==",2340- "dev": true,2341- "license": "MIT",2342- "engines": {2343- "node": ">=8"2344- }2345- },892 "node_modules/diff-sequences": {893 "version": "29.6.3",894 "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz",895 "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==",15 unmodified lines911 "engines": {912 "node": ">=8"913 }914 },2369- "node_modules/ejs": {2370- "version": "3.1.10",2371- "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",2372- "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",2373- "dev": true,2374- "license": "Apache-2.0",2375- "dependencies": {2376- "jake": "^10.8.5"2377- },2378- "bin": {2379- "ejs": "bin/cli.js"2380- },2381- "engines": {2382- "node": ">=0.10.0"2383- }2384- },2385- "node_modules/electron-to-chromium": {2386- "version": "1.5.123",2387- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.123.tgz",2388- "integrity": "sha512-refir3NlutEZqlKaBLK0tzlVLe5P2wDKS7UQt/3SpibizgsRAPOsqQC3ffw1nlv3ze5gjRQZYHoPymgVZkplFA==",2389- "dev": true,2390- "license": "ISC"2391- },2392- "node_modules/emittery": {2393- "version": "0.13.1",2394- "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz",2395- "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==",2396- "dev": true,2397- "license": "MIT",2398- "engines": {2399- "node": ">=12"2400- },2401- "funding": {2402- "url": "https://github.com/sindresorhus/emittery?sponsor=1"2403- }2404- },915 "node_modules/emoji-regex": {916 "version": "8.0.0",917 "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",918 "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",9 unmodified lines928 "dependencies": {929 "is-arrayish": "^0.2.1"930 }931 },2422- "node_modules/escalade": {2423- "version": "3.2.0",2424- "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",2425- "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",2426- "dev": true,2427- "license": "MIT",2428- "engines": {2429- "node": ">=6"2430- }2431- },932 "node_modules/escape-string-regexp": {933 "version": "4.0.0",934 "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",935 "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",11 unmodified lines947 "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.25.1.tgz",948 "integrity": "sha512-E6Mtz9oGQWDCpV12319d59n4tx9zOTXSTmc8BLVxBx+G/0RdM5MvEEJLU9c0+aleoePYYgVTOsRblx433qmhWQ==",949 "dev": true,950 "license": "MIT",951+ "peer": true,952 "dependencies": {953 "@eslint-community/eslint-utils": "^4.2.0",954 "@eslint-community/regexpp": "^4.12.1",955 "@eslint/config-array": "^0.20.0",83 unmodified lines1039 "funding": {1040 "url": "https://github.com/sponsors/sindresorhus"1041 }1042 },2542- "node_modules/eslint-plugin-jest": {2543- "version": "28.11.0",2544- "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.11.0.tgz",2545- "integrity": "sha512-QAfipLcNCWLVocVbZW8GimKn5p5iiMcgGbRzz8z/P5q7xw+cNEpYqyzFMtIF/ZgF2HLOyy+dYBut+DoYolvqig==",2546- "dev": true,2547- "license": "MIT",2548- "dependencies": {2549- "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0"2550- },2551- "engines": {2552- "node": "^16.10.0 || ^18.12.0 || >=20.0.0"2553- },2554- "peerDependencies": {2555- "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0",2556- "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",2557- "jest": "*"2558- },2559- "peerDependenciesMeta": {2560- "@typescript-eslint/eslint-plugin": {2561- "optional": true2562- },2563- "jest": {2564- "optional": true2565- }2566- }2567- },1043 "node_modules/eslint-rule-docs": {1044 "version": "1.1.235",1045 "resolved": "https://registry.npmjs.org/eslint-rule-docs/-/eslint-rule-docs-1.1.235.tgz",1046 "integrity": "sha512-+TQ+x4JdTnDoFEXXb3fDvfGOwnyNV7duH8fXWTPD1ieaBmB8omj7Gw/pMBBu4uI2uJCCU8APDaQJzWuXnTsH4A==",47 unmodified lines1094 "funding": {1095 "url": "https://opencollective.com/eslint"1096 }1097 },2623- "node_modules/esprima": {2624- "version": "4.0.1",2625- "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",2626- "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",2627- "dev": true,2628- "license": "BSD-2-Clause",2629- "bin": {2630- "esparse": "bin/esparse.js",2631- "esvalidate": "bin/esvalidate.js"2632- },2633- "engines": {2634- "node": ">=4"2635- }2636- },1098 "node_modules/esquery": {1099 "version": "1.6.0",1100 "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",1101 "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==",38 unmodified lines1140 "engines": {1141 "node": ">=0.10.0"1142 }1143 },2683- "node_modules/execa": {2684- "version": "5.1.1",2685- "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",2686- "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==",2687- "dev": true,2688- "license": "MIT",2689- "dependencies": {2690- "cross-spawn": "^7.0.3",2691- "get-stream": "^6.0.0",2692- "human-signals": "^2.1.0",2693- "is-stream": "^2.0.0",2694- "merge-stream": "^2.0.0",2695- "npm-run-path": "^4.0.1",2696- "onetime": "^5.1.2",2697- "signal-exit": "^3.0.3",2698- "strip-final-newline": "^2.0.0"2699- },2700- "engines": {2701- "node": ">=10"2702- },2703- "funding": {2704- "url": "https://github.com/sindresorhus/execa?sponsor=1"2705- }2706- },2707- "node_modules/exit": {2708- "version": "0.1.2",2709- "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz",2710- "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==",2711- "dev": true,2712- "engines": {2713- "node": ">= 0.8.0"2714- }2715- },2716- "node_modules/expect": {2717- "version": "29.7.0",2718- "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz",2719- "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==",2720- "dev": true,2721- "license": "MIT",2722- "dependencies": {2723- "@jest/expect-utils": "^29.7.0",2724- "jest-get-type": "^29.6.3",2725- "jest-matcher-utils": "^29.7.0",2726- "jest-message-util": "^29.7.0",2727- "jest-util": "^29.7.0"2728- },2729- "engines": {2730- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"2731- }2732- },1144 "node_modules/fast-deep-equal": {1145 "version": "3.1.3",1146 "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",1147 "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",53 unmodified lines1201 "dependencies": {1202 "reusify": "^1.0.4"1203 }1204 },2794- "node_modules/fb-watchman": {2795- "version": "2.0.2",2796- "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz",2797- "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==",2798- "dev": true,2799- "license": "Apache-2.0",2800- "dependencies": {2801- "bser": "2.1.1"2802- }2803- },1205 "node_modules/file-entry-cache": {1206 "version": "8.0.0",1207 "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",1208 "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==",5 unmodified lines1214 "engines": {1215 "node": ">=16.0.0"1216 }1217 },2817- "node_modules/filelist": {2818- "version": "1.0.4",2819- "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",2820- "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",2821- "dev": true,2822- "license": "Apache-2.0",2823- "dependencies": {2824- "minimatch": "^5.0.1"2825- }2826- },2827- "node_modules/filelist/node_modules/brace-expansion": {2828- "version": "2.0.1",2829- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",2830- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",2831- "dev": true,2832- "license": "MIT",2833- "dependencies": {2834- "balanced-match": "^1.0.0"2835- }2836- },2837- "node_modules/filelist/node_modules/minimatch": {2838- "version": "5.1.6",2839- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",2840- "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",2841- "dev": true,2842- "license": "ISC",2843- "dependencies": {2844- "brace-expansion": "^2.0.1"2845- },2846- "engines": {2847- "node": ">=10"2848- }2849- },1218 "node_modules/fill-range": {1219 "version": "7.1.1",1220 "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",1221 "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",43 unmodified lines1265 "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==",1266 "dev": true,1267 "license": "ISC"1268 },2901- "node_modules/fs.realpath": {2902- "version": "1.0.0",2903- "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",2904- "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",2905- "dev": true,2906- "license": "ISC"2907- },2908- "node_modules/fsevents": {2909- "version": "2.3.3",2910- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",2911- "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",2912- "dev": true,2913- "hasInstallScript": true,2914- "license": "MIT",2915- "optional": true,2916- "os": [2917- "darwin"2918- ],2919- "engines": {2920- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"2921- }2922- },1269 "node_modules/function-bind": {1270 "version": "1.1.2",1271 "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",1272 "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",2 unmodified lines1275 "funding": {1276 "url": "https://github.com/sponsors/ljharb"1277 }1278 },2933- "node_modules/gensync": {2934- "version": "1.0.0-beta.2",2935- "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",2936- "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",2937- "dev": true,2938- "license": "MIT",2939- "engines": {2940- "node": ">=6.9.0"2941- }2942- },2943- "node_modules/get-caller-file": {2944- "version": "2.0.5",2945- "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",2946- "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",2947- "dev": true,2948- "license": "ISC",2949- "engines": {2950- "node": "6.* || 8.* || >= 10.*"2951- }2952- },2953- "node_modules/get-package-type": {2954- "version": "0.1.0",2955- "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz",2956- "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==",2957- "dev": true,2958- "license": "MIT",2959- "engines": {2960- "node": ">=8.0.0"2961- }2962- },2963- "node_modules/get-stream": {2964- "version": "6.0.1",2965- "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",2966- "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",2967- "dev": true,2968- "license": "MIT",2969- "engines": {2970- "node": ">=10"2971- },2972- "funding": {2973- "url": "https://github.com/sponsors/sindresorhus"2974- }2975- },2976- "node_modules/glob": {2977- "version": "7.2.3",2978- "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",2979- "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",2980- "deprecated": "Glob versions prior to v9 are no longer supported",2981- "dev": true,2982- "license": "ISC",2983- "dependencies": {2984- "fs.realpath": "^1.0.0",2985- "inflight": "^1.0.4",2986- "inherits": "2",2987- "minimatch": "^3.1.1",2988- "once": "^1.3.0",2989- "path-is-absolute": "^1.0.0"2990- },2991- "engines": {2992- "node": "*"2993- },2994- "funding": {2995- "url": "https://github.com/sponsors/isaacs"2996- }2997- },1279 "node_modules/glob-parent": {1280 "version": "6.0.2",1281 "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",1282 "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",6 unmodified lines1289 "node": ">=10.13.0"1290 }1291 },1292 "node_modules/globals": {3012- "version": "16.0.0",3013- "resolved": "https://registry.npmjs.org/globals/-/globals-16.0.0.tgz",3014- "integrity": "sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A==",1293+ "version": "16.5.0",1294+ "resolved": "https://registry.npmjs.org/globals/-/globals-16.5.0.tgz",1295+ "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ==",1296 "dev": true,1297 "license": "MIT",1298 "engines": {1299 "node": ">=18"22 unmodified lines1322 "funding": {1323 "url": "https://github.com/sponsors/sindresorhus"1324 }1325 },3045- "node_modules/graceful-fs": {3046- "version": "4.2.11",3047- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",3048- "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",3049- "dev": true,3050- "license": "ISC"3051- },1326 "node_modules/graphemer": {1327 "version": "1.4.0",1328 "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",1329 "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",65 unmodified lines1395 "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",1396 "dev": true,1397 "license": "ISC"1398 },3125- "node_modules/html-escaper": {3126- "version": "2.0.2",3127- "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",3128- "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==",3129- "dev": true,3130- "license": "MIT"3131- },3132- "node_modules/human-signals": {3133- "version": "2.1.0",3134- "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",3135- "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==",3136- "dev": true,3137- "license": "Apache-2.0",3138- "engines": {3139- "node": ">=10.17.0"3140- }3141- },1399 "node_modules/ignore": {1400 "version": "5.3.2",1401 "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",1402 "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==",19 unmodified lines1422 "funding": {1423 "url": "https://github.com/sponsors/sindresorhus"1424 }1425 },3169- "node_modules/import-local": {3170- "version": "3.2.0",3171- "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz",3172- "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==",3173- "dev": true,3174- "license": "MIT",3175- "dependencies": {3176- "pkg-dir": "^4.2.0",3177- "resolve-cwd": "^3.0.0"3178- },3179- "bin": {3180- "import-local-fixture": "fixtures/cli.js"3181- },3182- "engines": {3183- "node": ">=8"3184- },3185- "funding": {3186- "url": "https://github.com/sponsors/sindresorhus"3187- }3188- },1426 "node_modules/imurmurhash": {1427 "version": "0.1.4",1428 "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",1429 "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",12 unmodified lines1442 "engines": {1443 "node": ">=8"1444 }1445 },3209- "node_modules/inflight": {3210- "version": "1.0.6",3211- "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",3212- "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",3213- "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",3214- "dev": true,3215- "license": "ISC",3216- "dependencies": {3217- "once": "^1.3.0",3218- "wrappy": "1"3219- }3220- },3221- "node_modules/inherits": {3222- "version": "2.0.4",3223- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",3224- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",3225- "dev": true,3226- "license": "ISC"3227- },1446 "node_modules/irregular-plurals": {1447 "version": "3.5.0",1448 "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.5.0.tgz",1449 "integrity": "sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ==",45 unmodified lines1495 "engines": {1496 "node": ">=8"1497 }1498 },3281- "node_modules/is-generator-fn": {3282- "version": "2.1.0",3283- "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz",3284- "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==",3285- "dev": true,3286- "license": "MIT",3287- "engines": {3288- "node": ">=6"3289- }3290- },1499 "node_modules/is-glob": {1500 "version": "4.0.3",1501 "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",1502 "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",25 unmodified lines1528 "engines": {1529 "node": ">=0.10.0"1530 }1531 },3324- "node_modules/is-stream": {3325- "version": "2.0.1",3326- "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",3327- "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",3328- "dev": true,3329- "license": "MIT",3330- "engines": {3331- "node": ">=8"3332- },3333- "funding": {3334- "url": "https://github.com/sponsors/sindresorhus"3335- }3336- },1532 "node_modules/is-unicode-supported": {1533 "version": "0.1.0",1534 "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",1535 "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",12 unmodified lines1548 "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",1549 "dev": true,1550 "license": "ISC"1551 },3357- "node_modules/istanbul-lib-coverage": {3358- "version": "3.2.2",3359- "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz",3360- "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==",3361- "dev": true,3362- "license": "BSD-3-Clause",3363- "engines": {3364- "node": ">=8"3365- }3366- },3367- "node_modules/istanbul-lib-instrument": {3368- "version": "6.0.3",3369- "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz",3370- "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==",3371- "dev": true,3372- "license": "BSD-3-Clause",3373- "dependencies": {3374- "@babel/core": "^7.23.9",3375- "@babel/parser": "^7.23.9",3376- "@istanbuljs/schema": "^0.1.3",3377- "istanbul-lib-coverage": "^3.2.0",3378- "semver": "^7.5.4"3379- },3380- "engines": {3381- "node": ">=10"3382- }3383- },3384- "node_modules/istanbul-lib-report": {3385- "version": "3.0.1",3386- "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz",3387- "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==",3388- "dev": true,3389- "license": "BSD-3-Clause",3390- "dependencies": {3391- "istanbul-lib-coverage": "^3.0.0",3392- "make-dir": "^4.0.0",3393- "supports-color": "^7.1.0"3394- },3395- "engines": {3396- "node": ">=10"3397- }3398- },3399- "node_modules/istanbul-lib-source-maps": {3400- "version": "4.0.1",3401- "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz",3402- "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==",3403- "dev": true,3404- "license": "BSD-3-Clause",3405- "dependencies": {3406- "debug": "^4.1.1",3407- "istanbul-lib-coverage": "^3.0.0",3408- "source-map": "^0.6.1"3409- },3410- "engines": {3411- "node": ">=10"3412- }3413- },3414- "node_modules/istanbul-reports": {3415- "version": "3.1.7",3416- "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz",3417- "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==",3418- "dev": true,3419- "license": "BSD-3-Clause",3420- "dependencies": {3421- "html-escaper": "^2.0.0",3422- "istanbul-lib-report": "^3.0.0"3423- },3424- "engines": {3425- "node": ">=8"3426- }3427- },3428- "node_modules/jake": {3429- "version": "10.9.2",3430- "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz",3431- "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==",3432- "dev": true,3433- "license": "Apache-2.0",3434- "dependencies": {3435- "async": "^3.2.3",3436- "chalk": "^4.0.2",3437- "filelist": "^1.0.4",3438- "minimatch": "^3.1.2"3439- },3440- "bin": {3441- "jake": "bin/cli.js"3442- },3443- "engines": {3444- "node": ">=10"3445- }3446- },3447- "node_modules/jest": {3448- "version": "29.7.0",3449- "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",3450- "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",3451- "dev": true,3452- "license": "MIT",3453- "dependencies": {3454- "@jest/core": "^29.7.0",3455- "@jest/types": "^29.6.3",3456- "import-local": "^3.0.2",3457- "jest-cli": "^29.7.0"3458- },3459- "bin": {3460- "jest": "bin/jest.js"3461- },3462- "engines": {3463- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3464- },3465- "peerDependencies": {3466- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"3467- },3468- "peerDependenciesMeta": {3469- "node-notifier": {3470- "optional": true3471- }3472- }3473- },3474- "node_modules/jest-changed-files": {3475- "version": "29.7.0",3476- "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz",3477- "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==",3478- "dev": true,3479- "license": "MIT",3480- "dependencies": {3481- "execa": "^5.0.0",3482- "jest-util": "^29.7.0",3483- "p-limit": "^3.1.0"3484- },3485- "engines": {3486- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3487- }3488- },3489- "node_modules/jest-circus": {3490- "version": "29.7.0",3491- "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz",3492- "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==",3493- "dev": true,3494- "license": "MIT",3495- "dependencies": {3496- "@jest/environment": "^29.7.0",3497- "@jest/expect": "^29.7.0",3498- "@jest/test-result": "^29.7.0",3499- "@jest/types": "^29.6.3",3500- "@types/node": "*",3501- "chalk": "^4.0.0",3502- "co": "^4.6.0",3503- "dedent": "^1.0.0",3504- "is-generator-fn": "^2.0.0",3505- "jest-each": "^29.7.0",3506- "jest-matcher-utils": "^29.7.0",3507- "jest-message-util": "^29.7.0",3508- "jest-runtime": "^29.7.0",3509- "jest-snapshot": "^29.7.0",3510- "jest-util": "^29.7.0",3511- "p-limit": "^3.1.0",3512- "pretty-format": "^29.7.0",3513- "pure-rand": "^6.0.0",3514- "slash": "^3.0.0",3515- "stack-utils": "^2.0.3"3516- },3517- "engines": {3518- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3519- }3520- },3521- "node_modules/jest-cli": {3522- "version": "29.7.0",3523- "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz",3524- "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==",3525- "dev": true,3526- "license": "MIT",3527- "dependencies": {3528- "@jest/core": "^29.7.0",3529- "@jest/test-result": "^29.7.0",3530- "@jest/types": "^29.6.3",3531- "chalk": "^4.0.0",3532- "create-jest": "^29.7.0",3533- "exit": "^0.1.2",3534- "import-local": "^3.0.2",3535- "jest-config": "^29.7.0",3536- "jest-util": "^29.7.0",3537- "jest-validate": "^29.7.0",3538- "yargs": "^17.3.1"3539- },3540- "bin": {3541- "jest": "bin/jest.js"3542- },3543- "engines": {3544- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3545- },3546- "peerDependencies": {3547- "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0"3548- },3549- "peerDependenciesMeta": {3550- "node-notifier": {3551- "optional": true3552- }3553- }3554- },3555- "node_modules/jest-config": {3556- "version": "29.7.0",3557- "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz",3558- "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==",3559- "dev": true,3560- "license": "MIT",3561- "dependencies": {3562- "@babel/core": "^7.11.6",3563- "@jest/test-sequencer": "^29.7.0",3564- "@jest/types": "^29.6.3",3565- "babel-jest": "^29.7.0",3566- "chalk": "^4.0.0",3567- "ci-info": "^3.2.0",3568- "deepmerge": "^4.2.2",3569- "glob": "^7.1.3",3570- "graceful-fs": "^4.2.9",3571- "jest-circus": "^29.7.0",3572- "jest-environment-node": "^29.7.0",3573- "jest-get-type": "^29.6.3",3574- "jest-regex-util": "^29.6.3",3575- "jest-resolve": "^29.7.0",3576- "jest-runner": "^29.7.0",3577- "jest-util": "^29.7.0",3578- "jest-validate": "^29.7.0",3579- "micromatch": "^4.0.4",3580- "parse-json": "^5.2.0",3581- "pretty-format": "^29.7.0",3582- "slash": "^3.0.0",3583- "strip-json-comments": "^3.1.1"3584- },3585- "engines": {3586- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3587- },3588- "peerDependencies": {3589- "@types/node": "*",3590- "ts-node": ">=9.0.0"3591- },3592- "peerDependenciesMeta": {3593- "@types/node": {3594- "optional": true3595- },3596- "ts-node": {3597- "optional": true3598- }3599- }3600- },1552 "node_modules/jest-diff": {1553 "version": "29.7.0",1554 "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz",1555 "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==",8 unmodified lines1564 "engines": {1565 "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1566 }1567 },3617- "node_modules/jest-docblock": {3618- "version": "29.7.0",3619- "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz",3620- "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==",3621- "dev": true,3622- "license": "MIT",3623- "dependencies": {3624- "detect-newline": "^3.0.0"3625- },3626- "engines": {3627- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3628- }3629- },3630- "node_modules/jest-each": {3631- "version": "29.7.0",3632- "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz",3633- "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==",3634- "dev": true,3635- "license": "MIT",3636- "dependencies": {3637- "@jest/types": "^29.6.3",3638- "chalk": "^4.0.0",3639- "jest-get-type": "^29.6.3",3640- "jest-util": "^29.7.0",3641- "pretty-format": "^29.7.0"3642- },3643- "engines": {3644- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3645- }3646- },3647- "node_modules/jest-environment-node": {3648- "version": "29.7.0",3649- "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz",3650- "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==",3651- "dev": true,3652- "license": "MIT",3653- "dependencies": {3654- "@jest/environment": "^29.7.0",3655- "@jest/fake-timers": "^29.7.0",3656- "@jest/types": "^29.6.3",3657- "@types/node": "*",3658- "jest-mock": "^29.7.0",3659- "jest-util": "^29.7.0"3660- },3661- "engines": {3662- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3663- }3664- },1568 "node_modules/jest-get-type": {1569 "version": "29.6.3",1570 "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz",1571 "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==",2 unmodified lines1574 "engines": {1575 "node": "^14.15.0 || ^16.10.0 || >=18.0.0"1576 }1577 },3675- "node_modules/jest-haste-map": {3676- "version": "29.7.0",3677- "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz",3678- "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==",3679- "dev": true,3680- "license": "MIT",3681- "dependencies": {3682- "@jest/types": "^29.6.3",3683- "@types/graceful-fs": "^4.1.3",3684- "@types/node": "*",3685- "anymatch": "^3.0.3",3686- "fb-watchman": "^2.0.0",3687- "graceful-fs": "^4.2.9",3688- "jest-regex-util": "^29.6.3",3689- "jest-util": "^29.7.0",3690- "jest-worker": "^29.7.0",3691- "micromatch": "^4.0.4",3692- "walker": "^1.0.8"3693- },3694- "engines": {3695- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3696- },3697- "optionalDependencies": {3698- "fsevents": "^2.3.2"3699- }3700- },3701- "node_modules/jest-leak-detector": {3702- "version": "29.7.0",3703- "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz",3704- "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==",3705- "dev": true,3706- "license": "MIT",3707- "dependencies": {3708- "jest-get-type": "^29.6.3",3709- "pretty-format": "^29.7.0"3710- },3711- "engines": {3712- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3713- }3714- },3715- "node_modules/jest-matcher-utils": {3716- "version": "29.7.0",3717- "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz",3718- "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==",3719- "dev": true,3720- "license": "MIT",3721- "dependencies": {3722- "chalk": "^4.0.0",3723- "jest-diff": "^29.7.0",3724- "jest-get-type": "^29.6.3",3725- "pretty-format": "^29.7.0"3726- },3727- "engines": {3728- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3729- }3730- },3731- "node_modules/jest-message-util": {3732- "version": "29.7.0",3733- "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz",3734- "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==",3735- "dev": true,3736- "license": "MIT",3737- "dependencies": {3738- "@babel/code-frame": "^7.12.13",3739- "@jest/types": "^29.6.3",3740- "@types/stack-utils": "^2.0.0",3741- "chalk": "^4.0.0",3742- "graceful-fs": "^4.2.9",3743- "micromatch": "^4.0.4",3744- "pretty-format": "^29.7.0",3745- "slash": "^3.0.0",3746- "stack-utils": "^2.0.3"3747- },3748- "engines": {3749- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3750- }3751- },3752- "node_modules/jest-mock": {3753- "version": "29.7.0",3754- "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz",3755- "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==",3756- "dev": true,3757- "license": "MIT",3758- "dependencies": {3759- "@jest/types": "^29.6.3",3760- "@types/node": "*",3761- "jest-util": "^29.7.0"3762- },3763- "engines": {3764- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3765- }3766- },3767- "node_modules/jest-pnp-resolver": {3768- "version": "1.2.3",3769- "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz",3770- "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==",3771- "dev": true,3772- "license": "MIT",3773- "engines": {3774- "node": ">=6"3775- },3776- "peerDependencies": {3777- "jest-resolve": "*"3778- },3779- "peerDependenciesMeta": {3780- "jest-resolve": {3781- "optional": true3782- }3783- }3784- },3785- "node_modules/jest-regex-util": {3786- "version": "29.6.3",3787- "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz",3788- "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==",3789- "dev": true,3790- "license": "MIT",3791- "engines": {3792- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3793- }3794- },3795- "node_modules/jest-resolve": {3796- "version": "29.7.0",3797- "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz",3798- "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==",3799- "dev": true,3800- "license": "MIT",3801- "dependencies": {3802- "chalk": "^4.0.0",3803- "graceful-fs": "^4.2.9",3804- "jest-haste-map": "^29.7.0",3805- "jest-pnp-resolver": "^1.2.2",3806- "jest-util": "^29.7.0",3807- "jest-validate": "^29.7.0",3808- "resolve": "^1.20.0",3809- "resolve.exports": "^2.0.0",3810- "slash": "^3.0.0"3811- },3812- "engines": {3813- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3814- }3815- },3816- "node_modules/jest-resolve-dependencies": {3817- "version": "29.7.0",3818- "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz",3819- "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==",3820- "dev": true,3821- "license": "MIT",3822- "dependencies": {3823- "jest-regex-util": "^29.6.3",3824- "jest-snapshot": "^29.7.0"3825- },3826- "engines": {3827- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3828- }3829- },3830- "node_modules/jest-runner": {3831- "version": "29.7.0",3832- "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz",3833- "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==",3834- "dev": true,3835- "license": "MIT",3836- "dependencies": {3837- "@jest/console": "^29.7.0",3838- "@jest/environment": "^29.7.0",3839- "@jest/test-result": "^29.7.0",3840- "@jest/transform": "^29.7.0",3841- "@jest/types": "^29.6.3",3842- "@types/node": "*",3843- "chalk": "^4.0.0",3844- "emittery": "^0.13.1",3845- "graceful-fs": "^4.2.9",3846- "jest-docblock": "^29.7.0",3847- "jest-environment-node": "^29.7.0",3848- "jest-haste-map": "^29.7.0",3849- "jest-leak-detector": "^29.7.0",3850- "jest-message-util": "^29.7.0",3851- "jest-resolve": "^29.7.0",3852- "jest-runtime": "^29.7.0",3853- "jest-util": "^29.7.0",3854- "jest-watcher": "^29.7.0",3855- "jest-worker": "^29.7.0",3856- "p-limit": "^3.1.0",3857- "source-map-support": "0.5.13"3858- },3859- "engines": {3860- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3861- }3862- },3863- "node_modules/jest-runtime": {3864- "version": "29.7.0",3865- "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz",3866- "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==",3867- "dev": true,3868- "license": "MIT",3869- "dependencies": {3870- "@jest/environment": "^29.7.0",3871- "@jest/fake-timers": "^29.7.0",3872- "@jest/globals": "^29.7.0",3873- "@jest/source-map": "^29.6.3",3874- "@jest/test-result": "^29.7.0",3875- "@jest/transform": "^29.7.0",3876- "@jest/types": "^29.6.3",3877- "@types/node": "*",3878- "chalk": "^4.0.0",3879- "cjs-module-lexer": "^1.0.0",3880- "collect-v8-coverage": "^1.0.0",3881- "glob": "^7.1.3",3882- "graceful-fs": "^4.2.9",3883- "jest-haste-map": "^29.7.0",3884- "jest-message-util": "^29.7.0",3885- "jest-mock": "^29.7.0",3886- "jest-regex-util": "^29.6.3",3887- "jest-resolve": "^29.7.0",3888- "jest-snapshot": "^29.7.0",3889- "jest-util": "^29.7.0",3890- "slash": "^3.0.0",3891- "strip-bom": "^4.0.0"3892- },3893- "engines": {3894- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3895- }3896- },3897- "node_modules/jest-snapshot": {3898- "version": "29.7.0",3899- "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz",3900- "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==",3901- "dev": true,3902- "license": "MIT",3903- "dependencies": {3904- "@babel/core": "^7.11.6",3905- "@babel/generator": "^7.7.2",3906- "@babel/plugin-syntax-jsx": "^7.7.2",3907- "@babel/plugin-syntax-typescript": "^7.7.2",3908- "@babel/types": "^7.3.3",3909- "@jest/expect-utils": "^29.7.0",3910- "@jest/transform": "^29.7.0",3911- "@jest/types": "^29.6.3",3912- "babel-preset-current-node-syntax": "^1.0.0",3913- "chalk": "^4.0.0",3914- "expect": "^29.7.0",3915- "graceful-fs": "^4.2.9",3916- "jest-diff": "^29.7.0",3917- "jest-get-type": "^29.6.3",3918- "jest-matcher-utils": "^29.7.0",3919- "jest-message-util": "^29.7.0",3920- "jest-util": "^29.7.0",3921- "natural-compare": "^1.4.0",3922- "pretty-format": "^29.7.0",3923- "semver": "^7.5.3"3924- },3925- "engines": {3926- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3927- }3928- },3929- "node_modules/jest-util": {3930- "version": "29.7.0",3931- "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz",3932- "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==",3933- "dev": true,3934- "license": "MIT",3935- "dependencies": {3936- "@jest/types": "^29.6.3",3937- "@types/node": "*",3938- "chalk": "^4.0.0",3939- "ci-info": "^3.2.0",3940- "graceful-fs": "^4.2.9",3941- "picomatch": "^2.2.3"3942- },3943- "engines": {3944- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3945- }3946- },3947- "node_modules/jest-validate": {3948- "version": "29.7.0",3949- "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz",3950- "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==",3951- "dev": true,3952- "license": "MIT",3953- "dependencies": {3954- "@jest/types": "^29.6.3",3955- "camelcase": "^6.2.0",3956- "chalk": "^4.0.0",3957- "jest-get-type": "^29.6.3",3958- "leven": "^3.1.0",3959- "pretty-format": "^29.7.0"3960- },3961- "engines": {3962- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3963- }3964- },3965- "node_modules/jest-validate/node_modules/camelcase": {3966- "version": "6.3.0",3967- "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",3968- "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",3969- "dev": true,3970- "license": "MIT",3971- "engines": {3972- "node": ">=10"3973- },3974- "funding": {3975- "url": "https://github.com/sponsors/sindresorhus"3976- }3977- },3978- "node_modules/jest-watcher": {3979- "version": "29.7.0",3980- "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz",3981- "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==",3982- "dev": true,3983- "license": "MIT",3984- "dependencies": {3985- "@jest/test-result": "^29.7.0",3986- "@jest/types": "^29.6.3",3987- "@types/node": "*",3988- "ansi-escapes": "^4.2.1",3989- "chalk": "^4.0.0",3990- "emittery": "^0.13.1",3991- "jest-util": "^29.7.0",3992- "string-length": "^4.0.1"3993- },3994- "engines": {3995- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"3996- }3997- },3998- "node_modules/jest-worker": {3999- "version": "29.7.0",4000- "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz",4001- "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==",4002- "dev": true,4003- "license": "MIT",4004- "dependencies": {4005- "@types/node": "*",4006- "jest-util": "^29.7.0",4007- "merge-stream": "^2.0.0",4008- "supports-color": "^8.0.0"4009- },4010- "engines": {4011- "node": "^14.15.0 || ^16.10.0 || >=18.0.0"4012- }4013- },4014- "node_modules/jest-worker/node_modules/supports-color": {4015- "version": "8.1.1",4016- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",4017- "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",4018- "dev": true,4019- "license": "MIT",4020- "dependencies": {4021- "has-flag": "^4.0.0"4022- },4023- "engines": {4024- "node": ">=10"4025- },4026- "funding": {4027- "url": "https://github.com/chalk/supports-color?sponsor=1"4028- }4029- },1578 "node_modules/js-tokens": {1579 "version": "4.0.0",1580 "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",1581 "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",12 unmodified lines1594 "bin": {1595 "js-yaml": "bin/js-yaml.js"1596 }1597 },4050- "node_modules/jsesc": {4051- "version": "3.1.0",4052- "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",4053- "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",4054- "dev": true,4055- "license": "MIT",4056- "bin": {4057- "jsesc": "bin/jsesc"4058- },4059- "engines": {4060- "node": ">=6"4061- }4062- },1598 "node_modules/json-buffer": {1599 "version": "3.0.1",1600 "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",1601 "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==",20 unmodified lines1622 "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==",1623 "dev": true,1624 "license": "MIT"1625 },4091- "node_modules/json5": {4092- "version": "2.2.3",4093- "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",4094- "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",4095- "dev": true,4096- "license": "MIT",4097- "bin": {4098- "json5": "lib/cli.js"4099- },4100- "engines": {4101- "node": ">=6"4102- }4103- },1626 "node_modules/keyv": {1627 "version": "4.5.4",1628 "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",1629 "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",12 unmodified lines1642 "engines": {1643 "node": ">=0.10.0"1644 }1645 },4124- "node_modules/kleur": {4125- "version": "3.0.3",4126- "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",4127- "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",4128- "dev": true,4129- "license": "MIT",4130- "engines": {4131- "node": ">=6"4132- }4133- },4134- "node_modules/leven": {4135- "version": "3.1.0",4136- "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",4137- "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==",4138- "dev": true,4139- "license": "MIT",4140- "engines": {4141- "node": ">=6"4142- }4143- },1646 "node_modules/levn": {1647 "version": "0.4.1",1648 "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",1649 "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",29 unmodified lines1679 "funding": {1680 "url": "https://github.com/sponsors/sindresorhus"1681 }1682 },4181- "node_modules/lodash.memoize": {4182- "version": "4.1.2",4183- "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",4184- "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==",4185- "dev": true,4186- "license": "MIT"4187- },1683 "node_modules/lodash.merge": {1684 "version": "4.6.2",1685 "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",1686 "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",16 unmodified lines1703 "funding": {1704 "url": "https://github.com/sponsors/sindresorhus"1705 }1706 },4212- "node_modules/lru-cache": {4213- "version": "5.1.1",4214- "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",4215- "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",4216- "dev": true,4217- "license": "ISC",4218- "dependencies": {4219- "yallist": "^3.0.2"4220- }4221- },4222- "node_modules/make-dir": {4223- "version": "4.0.0",4224- "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",4225- "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==",4226- "dev": true,4227- "license": "MIT",4228- "dependencies": {4229- "semver": "^7.5.3"4230- },4231- "engines": {4232- "node": ">=10"4233- },4234- "funding": {4235- "url": "https://github.com/sponsors/sindresorhus"4236- }4237- },4238- "node_modules/make-error": {4239- "version": "1.3.6",4240- "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",4241- "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",4242- "dev": true,4243- "license": "ISC"4244- },4245- "node_modules/makeerror": {4246- "version": "1.0.12",4247- "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz",4248- "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==",4249- "dev": true,4250- "license": "BSD-3-Clause",4251- "dependencies": {4252- "tmpl": "1.0.5"4253- }4254- },1707 "node_modules/map-obj": {1708 "version": "4.3.0",1709 "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz",1710 "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==",55 unmodified lines1766 "engines": {1767 "node": ">=10"1768 }1769 },4318- "node_modules/merge-stream": {4319- "version": "2.0.0",4320- "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",4321- "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",4322- "dev": true,4323- "license": "MIT"4324- },1770 "node_modules/merge2": {1771 "version": "1.4.1",1772 "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",1773 "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",16 unmodified lines1790 "engines": {1791 "node": ">=8.6"1792 }1793 },4349- "node_modules/mimic-fn": {4350- "version": "2.1.0",4351- "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",4352- "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",4353- "dev": true,4354- "license": "MIT",4355- "engines": {4356- "node": ">=6"4357- }4358- },1794 "node_modules/min-indent": {1795 "version": "1.0.1",1796 "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",1797 "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==",44 unmodified lines1842 "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",1843 "dev": true,1844 "license": "MIT"1845 },4411- "node_modules/node-int64": {4412- "version": "0.4.0",4413- "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",4414- "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",4415- "dev": true,4416- "license": "MIT"4417- },4418- "node_modules/node-releases": {4419- "version": "2.0.19",4420- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz",4421- "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==",4422- "dev": true,4423- "license": "MIT"4424- },1846 "node_modules/normalize-package-data": {1847 "version": "3.0.3",1848 "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz",1849 "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==",8 unmodified lines1858 "engines": {1859 "node": ">=10"1860 }1861 },4441- "node_modules/normalize-path": {4442- "version": "3.0.0",4443- "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",4444- "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",4445- "dev": true,4446- "license": "MIT",4447- "engines": {4448- "node": ">=0.10.0"4449- }4450- },4451- "node_modules/npm-run-path": {4452- "version": "4.0.1",4453- "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",4454- "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",4455- "dev": true,4456- "license": "MIT",4457- "dependencies": {4458- "path-key": "^3.0.0"4459- },4460- "engines": {4461- "node": ">=8"4462- }4463- },4464- "node_modules/once": {4465- "version": "1.4.0",4466- "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",4467- "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",4468- "dev": true,4469- "license": "ISC",4470- "dependencies": {4471- "wrappy": "1"4472- }4473- },4474- "node_modules/onetime": {4475- "version": "5.1.2",4476- "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",4477- "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",4478- "dev": true,4479- "license": "MIT",4480- "dependencies": {4481- "mimic-fn": "^2.1.0"4482- },4483- "engines": {4484- "node": ">=6"4485- },4486- "funding": {4487- "url": "https://github.com/sponsors/sindresorhus"4488- }4489- },1862 "node_modules/optionator": {1863 "version": "0.9.4",1864 "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",1865 "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==",94 unmodified lines1960 "engines": {1961 "node": ">=8"1962 }1963 },4592- "node_modules/path-is-absolute": {4593- "version": "1.0.1",4594- "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",4595- "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",4596- "dev": true,4597- "license": "MIT",4598- "engines": {4599- "node": ">=0.10.0"4600- }4601- },1964 "node_modules/path-key": {1965 "version": "3.1.1",1966 "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",1967 "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",39 unmodified lines2007 "funding": {2008 "url": "https://github.com/sponsors/jonschlinkert"2009 }2010 },4649- "node_modules/pirates": {4650- "version": "4.0.6",4651- "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz",4652- "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==",4653- "dev": true,4654- "license": "MIT",4655- "engines": {4656- "node": ">= 6"4657- }4658- },4659- "node_modules/pkg-dir": {4660- "version": "4.2.0",4661- "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",4662- "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",4663- "dev": true,4664- "license": "MIT",4665- "dependencies": {4666- "find-up": "^4.0.0"4667- },4668- "engines": {4669- "node": ">=8"4670- }4671- },4672- "node_modules/pkg-dir/node_modules/find-up": {4673- "version": "4.1.0",4674- "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",4675- "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",4676- "dev": true,4677- "license": "MIT",4678- "dependencies": {4679- "locate-path": "^5.0.0",4680- "path-exists": "^4.0.0"4681- },4682- "engines": {4683- "node": ">=8"4684- }4685- },4686- "node_modules/pkg-dir/node_modules/locate-path": {4687- "version": "5.0.0",4688- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",4689- "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",4690- "dev": true,4691- "license": "MIT",4692- "dependencies": {4693- "p-locate": "^4.1.0"4694- },4695- "engines": {4696- "node": ">=8"4697- }4698- },4699- "node_modules/pkg-dir/node_modules/p-limit": {4700- "version": "2.3.0",4701- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",4702- "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",4703- "dev": true,4704- "license": "MIT",4705- "dependencies": {4706- "p-try": "^2.0.0"4707- },4708- "engines": {4709- "node": ">=6"4710- },4711- "funding": {4712- "url": "https://github.com/sponsors/sindresorhus"4713- }4714- },4715- "node_modules/pkg-dir/node_modules/p-locate": {4716- "version": "4.1.0",4717- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",4718- "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",4719- "dev": true,4720- "license": "MIT",4721- "dependencies": {4722- "p-limit": "^2.2.0"4723- },4724- "engines": {4725- "node": ">=8"4726- }4727- },2011 "node_modules/plur": {2012 "version": "4.0.0",2013 "resolved": "https://registry.npmjs.org/plur/-/plur-4.0.0.tgz",2014 "integrity": "sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg==",62 unmodified lines2077 "funding": {2078 "url": "https://github.com/chalk/ansi-styles?sponsor=1"2079 }2080 },4798- "node_modules/prompts": {4799- "version": "2.4.2",4800- "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",4801- "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==",4802- "dev": true,4803- "license": "MIT",4804- "dependencies": {4805- "kleur": "^3.0.3",4806- "sisteransi": "^1.0.5"4807- },4808- "engines": {4809- "node": ">= 6"4810- }4811- },2081 "node_modules/punycode": {2082 "version": "2.3.1",2083 "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",2084 "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",2 unmodified lines2087 "engines": {2088 "node": ">=6"2089 }2090 },4822- "node_modules/pure-rand": {4823- "version": "6.1.0",4824- "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz",4825- "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==",4826- "dev": true,4827- "funding": [4828- {4829- "type": "individual",4830- "url": "https://github.com/sponsors/dubzzz"4831- },4832- {4833- "type": "opencollective",4834- "url": "https://opencollective.com/fast-check"4835- }4836- ],4837- "license": "MIT"4838- },2091 "node_modules/queue-microtask": {2092 "version": "1.2.3",2093 "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",2094 "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",184 unmodified lines2279 "engines": {2280 "node": ">=8"2281 }2282 },5031- "node_modules/require-directory": {5032- "version": "2.1.1",5033- "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",5034- "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",5035- "dev": true,5036- "license": "MIT",5037- "engines": {5038- "node": ">=0.10.0"5039- }5040- },2283 "node_modules/resolve": {2284 "version": "1.22.10",2285 "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz",2286 "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==",13 unmodified lines2300 "funding": {2301 "url": "https://github.com/sponsors/ljharb"2302 }2303 },5062- "node_modules/resolve-cwd": {5063- "version": "3.0.0",5064- "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",5065- "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",5066- "dev": true,5067- "license": "MIT",5068- "dependencies": {5069- "resolve-from": "^5.0.0"5070- },5071- "engines": {5072- "node": ">=8"5073- }5074- },5075- "node_modules/resolve-cwd/node_modules/resolve-from": {5076- "version": "5.0.0",5077- "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",5078- "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",5079- "dev": true,5080- "license": "MIT",5081- "engines": {5082- "node": ">=8"5083- }5084- },2304 "node_modules/resolve-from": {2305 "version": "4.0.0",2306 "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",2307 "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",2 unmodified lines2310 "engines": {2311 "node": ">=4"2312 }2313 },5095- "node_modules/resolve.exports": {5096- "version": "2.0.3",5097- "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.3.tgz",5098- "integrity": "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==",5099- "dev": true,5100- "license": "MIT",5101- "engines": {5102- "node": ">=10"5103- }5104- },2314 "node_modules/reusify": {2315 "version": "1.1.0",2316 "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",2317 "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",63 unmodified lines2381 "engines": {2382 "node": ">=8"2383 }2384 },5176- "node_modules/signal-exit": {5177- "version": "3.0.7",5178- "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",5179- "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==",5180- "dev": true,5181- "license": "ISC"5182- },5183- "node_modules/sisteransi": {5184- "version": "1.0.5",5185- "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",5186- "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==",5187- "dev": true,5188- "license": "MIT"5189- },2385 "node_modules/slash": {2386 "version": "3.0.0",2387 "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",2388 "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",2 unmodified lines2391 "engines": {2392 "node": ">=8"2393 }2394 },5200- "node_modules/source-map": {5201- "version": "0.6.1",5202- "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",5203- "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",5204- "dev": true,5205- "license": "BSD-3-Clause",5206- "engines": {5207- "node": ">=0.10.0"5208- }5209- },5210- "node_modules/source-map-support": {5211- "version": "0.5.13",5212- "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz",5213- "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==",5214- "dev": true,5215- "license": "MIT",5216- "dependencies": {5217- "buffer-from": "^1.0.0",5218- "source-map": "^0.6.0"5219- }5220- },2395 "node_modules/spdx-correct": {2396 "version": "3.2.0",2397 "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz",2398 "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==",28 unmodified lines2427 "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==",2428 "dev": true,2429 "license": "CC0-1.0"2430 },5257- "node_modules/sprintf-js": {5258- "version": "1.0.3",5259- "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",5260- "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",5261- "dev": true,5262- "license": "BSD-3-Clause"5263- },5264- "node_modules/stack-utils": {5265- "version": "2.0.6",5266- "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz",5267- "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==",5268- "dev": true,5269- "license": "MIT",5270- "dependencies": {5271- "escape-string-regexp": "^2.0.0"5272- },5273- "engines": {5274- "node": ">=10"5275- }5276- },5277- "node_modules/stack-utils/node_modules/escape-string-regexp": {5278- "version": "2.0.0",5279- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",5280- "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",5281- "dev": true,5282- "license": "MIT",5283- "engines": {5284- "node": ">=8"5285- }5286- },5287- "node_modules/string-length": {5288- "version": "4.0.2",5289- "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz",5290- "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==",5291- "dev": true,5292- "license": "MIT",5293- "dependencies": {5294- "char-regex": "^1.0.2",5295- "strip-ansi": "^6.0.0"5296- },5297- "engines": {5298- "node": ">=10"5299- }5300- },2431 "node_modules/string-width": {2432 "version": "4.2.3",2433 "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",2434 "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",20 unmodified lines2455 "engines": {2456 "node": ">=8"2457 }2458 },5329- "node_modules/strip-bom": {5330- "version": "4.0.0",5331- "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz",5332- "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==",5333- "dev": true,5334- "license": "MIT",5335- "engines": {5336- "node": ">=8"5337- }5338- },5339- "node_modules/strip-final-newline": {5340- "version": "2.0.0",5341- "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",5342- "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",5343- "dev": true,5344- "license": "MIT",5345- "engines": {5346- "node": ">=6"5347- }5348- },2459 "node_modules/strip-indent": {2460 "version": "3.0.0",2461 "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz",2462 "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==",58 unmodified lines2521 "funding": {2522 "url": "https://github.com/sponsors/ljharb"2523 }2524 },5415- "node_modules/test-exclude": {5416- "version": "6.0.0",5417- "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz",5418- "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==",5419- "dev": true,5420- "license": "ISC",5421- "dependencies": {5422- "@istanbuljs/schema": "^0.1.2",5423- "glob": "^7.1.4",5424- "minimatch": "^3.0.4"5425- },5426- "engines": {5427- "node": ">=8"5428- }5429- },5430- "node_modules/tmpl": {5431- "version": "1.0.5",5432- "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",5433- "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==",5434- "dev": true,5435- "license": "BSD-3-Clause"5436- },2525 "node_modules/to-regex-range": {2526 "version": "5.0.1",2527 "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",2528 "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",28 unmodified lines2557 "peerDependencies": {2558 "typescript": ">=4.8.4"2559 }2560 },5473- "node_modules/ts-jest": {5474- "version": "29.3.1",5475- "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.1.tgz",5476- "integrity": "sha512-FT2PIRtZABwl6+ZCry8IY7JZ3xMuppsEV9qFVHOVe8jDzggwUZ9TsM4chyJxL9yi6LvkqcZYU3LmapEE454zBQ==",5477- "dev": true,5478- "license": "MIT",5479- "dependencies": {5480- "bs-logger": "^0.2.6",5481- "ejs": "^3.1.10",5482- "fast-json-stable-stringify": "^2.1.0",5483- "jest-util": "^29.0.0",5484- "json5": "^2.2.3",5485- "lodash.memoize": "^4.1.2",5486- "make-error": "^1.3.6",5487- "semver": "^7.7.1",5488- "type-fest": "^4.38.0",5489- "yargs-parser": "^21.1.1"5490- },5491- "bin": {5492- "ts-jest": "cli.js"5493- },5494- "engines": {5495- "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"5496- },5497- "peerDependencies": {5498- "@babel/core": ">=7.0.0-beta.0 <8",5499- "@jest/transform": "^29.0.0",5500- "@jest/types": "^29.0.0",5501- "babel-jest": "^29.0.0",5502- "jest": "^29.0.0",5503- "typescript": ">=4.3 <6"5504- },5505- "peerDependenciesMeta": {5506- "@babel/core": {5507- "optional": true5508- },5509- "@jest/transform": {5510- "optional": true5511- },5512- "@jest/types": {5513- "optional": true5514- },5515- "babel-jest": {5516- "optional": true5517- },5518- "esbuild": {5519- "optional": true5520- }5521- }5522- },5523- "node_modules/ts-jest/node_modules/type-fest": {5524- "version": "4.38.0",5525- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.38.0.tgz",5526- "integrity": "sha512-2dBz5D5ycHIoliLYLi0Q2V7KRaDlH0uWIvmk7TYlAg5slqwiPv1ezJdZm1QEM0xgk29oYWMCbIG7E6gHpvChlg==",5527- "dev": true,5528- "license": "(MIT OR CC0-1.0)",5529- "engines": {5530- "node": ">=16"5531- },5532- "funding": {5533- "url": "https://github.com/sponsors/sindresorhus"5534- }5535- },2561 "node_modules/tsd": {2562 "version": "0.31.2",2563 "resolved": "https://registry.npmjs.org/tsd/-/tsd-0.31.2.tgz",2564 "integrity": "sha512-VplBAQwvYrHzVihtzXiUVXu5bGcr7uH1juQZ1lmKgkuGNGT+FechUCqmx9/zk7wibcqR2xaNEwCkDyKh+VVZnQ==",27 unmodified lines2592 "engines": {2593 "node": ">= 0.8.0"2594 }2595 },5571- "node_modules/type-detect": {5572- "version": "4.0.8",5573- "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",5574- "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",5575- "dev": true,5576- "license": "MIT",5577- "engines": {5578- "node": ">=4"5579- }5580- },2596 "node_modules/type-fest": {2597 "version": "0.21.3",2598 "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz",2599 "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",11 unmodified lines2611 "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",2612 "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",2613 "dev": true,2614 "license": "Apache-2.0",2615+ "peer": true,2616 "bin": {2617 "tsc": "bin/tsc",2618 "tsserver": "bin/tsserver"2619 },30 unmodified lines2650 "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",2651 "dev": true,2652 "license": "MIT"2653 },5638- "node_modules/update-browserslist-db": {5639- "version": "1.1.3",5640- "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz",5641- "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==",5642- "dev": true,5643- "funding": [5644- {5645- "type": "opencollective",5646- "url": "https://opencollective.com/browserslist"5647- },5648- {5649- "type": "tidelift",5650- "url": "https://tidelift.com/funding/github/npm/browserslist"5651- },5652- {5653- "type": "github",5654- "url": "https://github.com/sponsors/ai"5655- }5656- ],5657- "license": "MIT",5658- "dependencies": {5659- "escalade": "^3.2.0",5660- "picocolors": "^1.1.1"5661- },5662- "bin": {5663- "update-browserslist-db": "cli.js"5664- },5665- "peerDependencies": {5666- "browserslist": ">= 4.21.0"5667- }5668- },2654 "node_modules/uri-js": {2655 "version": "4.4.1",2656 "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",2657 "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",2 unmodified lines2660 "dependencies": {2661 "punycode": "^2.1.0"2662 }2663 },5679- "node_modules/v8-to-istanbul": {5680- "version": "9.3.0",5681- "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",5682- "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==",5683- "dev": true,5684- "license": "ISC",5685- "dependencies": {5686- "@jridgewell/trace-mapping": "^0.3.12",5687- "@types/istanbul-lib-coverage": "^2.0.1",5688- "convert-source-map": "^2.0.0"5689- },5690- "engines": {5691- "node": ">=10.12.0"5692- }5693- },2664 "node_modules/validate-npm-package-license": {2665 "version": "3.0.4",2666 "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",2667 "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",3 unmodified lines2671 "spdx-correct": "^3.0.0",2672 "spdx-expression-parse": "^3.0.0"2673 }2674 },5705- "node_modules/walker": {5706- "version": "1.0.8",5707- "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz",5708- "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==",5709- "dev": true,5710- "license": "Apache-2.0",5711- "dependencies": {5712- "makeerror": "1.0.12"5713- }5714- },2675 "node_modules/which": {2676 "version": "2.0.2",2677 "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",2678 "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",18 unmodified lines2697 "engines": {2698 "node": ">=0.10.0"2699 }2700 },5741- "node_modules/wrap-ansi": {5742- "version": "7.0.0",5743- "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",5744- "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",5745- "dev": true,5746- "license": "MIT",5747- "dependencies": {5748- "ansi-styles": "^4.0.0",5749- "string-width": "^4.1.0",5750- "strip-ansi": "^6.0.0"5751- },5752- "engines": {5753- "node": ">=10"5754- },5755- "funding": {5756- "url": "https://github.com/chalk/wrap-ansi?sponsor=1"5757- }5758- },5759- "node_modules/wrappy": {5760- "version": "1.0.2",5761- "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",5762- "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",5763- "dev": true,5764- "license": "ISC"5765- },5766- "node_modules/write-file-atomic": {5767- "version": "4.0.2",5768- "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz",5769- "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==",5770- "dev": true,5771- "license": "ISC",5772- "dependencies": {5773- "imurmurhash": "^0.1.4",5774- "signal-exit": "^3.0.7"5775- },5776- "engines": {5777- "node": "^12.13.0 || ^14.15.0 || >=16.0.0"5778- }5779- },5780- "node_modules/y18n": {5781- "version": "5.0.8",5782- "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",5783- "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",5784- "dev": true,5785- "license": "ISC",5786- "engines": {5787- "node": ">=10"5788- }5789- },5790- "node_modules/yallist": {5791- "version": "3.1.1",5792- "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",5793- "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",5794- "dev": true,5795- "license": "ISC"5796- },5797- "node_modules/yargs": {5798- "version": "17.7.2",5799- "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",5800- "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",5801- "dev": true,5802- "license": "MIT",5803- "dependencies": {5804- "cliui": "^8.0.1",5805- "escalade": "^3.1.1",5806- "get-caller-file": "^2.0.5",5807- "require-directory": "^2.1.1",5808- "string-width": "^4.2.3",5809- "y18n": "^5.0.5",5810- "yargs-parser": "^21.1.1"5811- },5812- "engines": {5813- "node": ">=12"5814- }5815- },5816- "node_modules/yargs-parser": {5817- "version": "21.1.1",5818- "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",5819- "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",5820- "dev": true,5821- "license": "ISC",5822- "engines": {5823- "node": ">=12"5824- }5825- },2701 "node_modules/yocto-queue": {2702 "version": "0.1.0",2703 "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",2704 "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",11 unmodified linesmodified:package.json+2 added-7 removed
26 unmodified lines27 "check:type:js": "tsc -p tsconfig.js.json",28 "fix": "npm run fix:lint && npm run fix:format",29 "fix:format": "prettier --write .",30 "fix:lint": "eslint --fix .",31- "test": "jest && npm run check:type:ts",32- "test-all": "jest && npm run test-esm && npm run check",33- "test-esm": "node ./tests/esm-imports-test.mjs"31+ "test": "node --test && npm run check:type:ts",32+ "test-all": "node --test && npm run check"33 },34 "files": [35 "index.js",36 "lib/*.js",22 unmodified lines59 }60 },61 "devDependencies": {62 "@eslint/js": "^9.4.0",64- "@types/jest": "^29.2.4",63 "@types/node": "^22.7.4",64 "eslint": "^9.17.0",65 "eslint-config-prettier": "^10.0.1",68- "eslint-plugin-jest": "^28.3.0",66 "globals": "^16.0.0",70- "jest": "^29.3.1",67 "prettier": "^3.2.5",72- "ts-jest": "^29.0.3",68 "tsd": "^0.31.0",69 "typescript": "^5.0.4",70 "typescript-eslint": "^8.12.2"71 },6 unmodified linesmodified:tsconfig.json+1 added-1 removed
21 unmodified lines22 "noImplicitAny": false,23 "strictNullChecks": false,24 "useUnknownInCatchVariables": false,25 26- "types": ["node", "jest"],26+ "types": ["node"],27 "noEmit": true /* just type checking and not emitting transpiled files */,28 "skipLibCheck": false /* we want to check our hand crafted definitions */,29 "forceConsistentCasingInFileNames": true,30 "esModuleInterop": true /* common TypeScript config */,14 unmodified lines