diff --git a/bin/ui5.js b/bin/ui5.js index 618a20cd..0a7bcc16 100755 --- a/bin/ui5.js +++ b/bin/ui5.js @@ -37,13 +37,18 @@ setTimeout(() => { } const updateNotifier = require("update-notifier"); - const cli = require("yargs"); - updateNotifier({ pkg, updateCheckInterval: 1000 * 60 * 60 * 24, // 1 day shouldNotifyInNpmScript: true }).notify(); + // Remove --no-update-notifier from argv as it's not known to yargs, but we still want to support using it + const NO_UPDATE_NOTIFIER = "--no-update-notifier"; + if (process.argv.includes(NO_UPDATE_NOTIFIER)) { + process.argv = process.argv.filter((v) => v !== NO_UPDATE_NOTIFIER); + } + + const cli = require("yargs"); cli.parserConfiguration({ "parse-numbers": false diff --git a/test/lib/cli/commands/base.js b/test/lib/cli/commands/base.js index 05b5b508..b41bbb54 100644 --- a/test/lib/cli/commands/base.js +++ b/test/lib/cli/commands/base.js @@ -45,7 +45,6 @@ test("Exception error handling", async (t) => { t.deepEqual(err.exitCode, 1, "Process was exited with code 1"); }); - test("Exception error handling with verbose logging", async (t) => { // This test depends on the init command throwing on projects that already have a ui5.yaml @@ -67,3 +66,9 @@ test("Exception error handling with verbose logging", async (t) => { t.deepEqual(err.exitCode, 1, "Process was exited with code 1"); }); + +test("ui5 --no-update-notifier", async (t) => { + const {stdout, failed} = await ui5(["versions", "--no-update-notifier"]); + t.regex(stdout, /@ui5\/cli:/, "Output includes version information"); + t.false(failed, "Command should not fail"); +});