From 7a1d8da01bb12133f77aca161fbd301911bcaa67 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Wed, 12 Nov 2025 15:09:24 -0800 Subject: [PATCH 1/2] Fix: vebose option should error if no number is given --- src/util.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util.js b/src/util.js index 86a5dc12..febe4125 100644 --- a/src/util.js +++ b/src/util.js @@ -212,6 +212,14 @@ async function e_call(argv, script, ...args) { return; } + if (argv.verbose !== undefined && + // this must exclude NaN -- yargs default value for numeric type + !(argv.verbose >= 0 && argv.verbose <= 5)) { + console.warn("invalid value for --verbose option: must be a number between 0 and 5"); + process.exit(1); + return; + } + return new Promise(resolve => { let _path = el_script(script); From 84b2d754a2dd1a7d7511aff49c4158c1dfc7a738 Mon Sep 17 00:00:00 2001 From: Josh Bax Date: Wed, 12 Nov 2025 15:15:12 -0800 Subject: [PATCH 2/2] Add tests for verbose option --- test/jest/options.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/jest/options.test.js b/test/jest/options.test.js index bcc97e0b..42aa4323 100644 --- a/test/jest/options.test.js +++ b/test/jest/options.test.js @@ -18,6 +18,18 @@ describe("options", () => { }); }); + describe("verbose option", () => { + it("should error if no number is given", async () => { + await expect(ctx.runEask("info -v")).rejects.toMatchObject({ code: 1 }); + }); + + it("should error if the number is omitted before the next option", async () => { + await expect(ctx.runEask("info -v --no-color")).rejects.toMatchObject({ + code: 1, + }); + }); + }); + test.each([ "-a", "--all",