From e617ade40534ae8caef2a1a8986b1c9d3c03c5dd Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 21 Feb 2026 17:09:40 +1300 Subject: [PATCH 1/3] Use simple match in test (to avoid warning about expensive regex) --- tests/command.help.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/command.help.test.js b/tests/command.help.test.js index 6046e034c..74f1c284b 100644 --- a/tests/command.help.test.js +++ b/tests/command.help.test.js @@ -118,9 +118,14 @@ Commands: test('when help short flag masked then not displayed in helpInformation', () => { const program = new commander.Command(); + program.option('-o, --ordinary', 'select host'); program.option('-h, --host', 'select host'); const helpInformation = program.helpInformation(); - assert(!/\W-h\W.*display help/.test(helpInformation)); + // sanity check how option is normally displayed + assert(helpInformation.includes('-o, --ordinary')); + // check help listed as --help not -h, --help + assert(helpInformation.includes('--help')); + assert(!helpInformation.includes('-h, --help')); }); test('when both help flags masked then not displayed in helpInformation', () => { From 96123a16782b487116ac1d7fd21e24e02cb2579e Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 21 Feb 2026 17:17:46 +1300 Subject: [PATCH 2/3] Improve clarity --- tests/command.help.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/command.help.test.js b/tests/command.help.test.js index 74f1c284b..317e47bd4 100644 --- a/tests/command.help.test.js +++ b/tests/command.help.test.js @@ -118,7 +118,10 @@ Commands: test('when help short flag masked then not displayed in helpInformation', () => { const program = new commander.Command(); - program.option('-o, --ordinary', 'select host'); + program.option( + '-o, --ordinary', + 'example option for checking expected help format', + ); program.option('-h, --host', 'select host'); const helpInformation = program.helpInformation(); // sanity check how option is normally displayed From 44ad6638195cfc779fbfd5868d15aa3ba0f57f1b Mon Sep 17 00:00:00 2001 From: John Gee Date: Sat, 21 Feb 2026 19:06:03 +1300 Subject: [PATCH 3/3] Remove unnecessary extra option in test --- tests/command.help.test.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/command.help.test.js b/tests/command.help.test.js index 317e47bd4..030cb858b 100644 --- a/tests/command.help.test.js +++ b/tests/command.help.test.js @@ -118,17 +118,11 @@ Commands: test('when help short flag masked then not displayed in helpInformation', () => { const program = new commander.Command(); - program.option( - '-o, --ordinary', - 'example option for checking expected help format', - ); program.option('-h, --host', 'select host'); const helpInformation = program.helpInformation(); - // sanity check how option is normally displayed - assert(helpInformation.includes('-o, --ordinary')); - // check help listed as --help not -h, --help - assert(helpInformation.includes('--help')); - assert(!helpInformation.includes('-h, --help')); + assert(helpInformation.includes(' -h, --host')); + assert(!helpInformation.includes(' -h, --help')); + assert(helpInformation.includes(' --help')); }); test('when both help flags masked then not displayed in helpInformation', () => {