Skip to content

Commit

Permalink
[FIX] Allow use of --no-update-notifier flag
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Aug 31, 2020
1 parent a3cc049 commit a34b58c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions bin/ui5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion test/lib/cli/commands/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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");
});

0 comments on commit a34b58c

Please sign in to comment.