Skip to content

Commit 61255cc

Browse files
committed
feat(cli): add update notifier to remind cli upgrade
1 parent 90a0bfb commit 61255cc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/cli/bin/cli-main.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
const checkNodeVersion = require('@loopback/dist-util').checkNodeVersion;
1010

11+
const pkg = require('../package.json');
1112
try {
12-
const range = require('../package.json').engines.node;
13+
const range = pkg.engines.node;
1314
checkNodeVersion(range);
1415
} catch (e) {
1516
console.error(e.message);
@@ -26,4 +27,13 @@ const opts = minimist(process.argv.slice(2), {
2627
commands: 'l', // --commands or -l: print commands
2728
},
2829
});
30+
31+
const updateNotifier = require('update-notifier');
32+
// Force version check with `lb4 --version`
33+
const interval = opts.version ? 0 : undefined;
34+
updateNotifier({
35+
pkg: pkg,
36+
updateCheckInterval: interval,
37+
}).notify({isGlobal: true});
38+
2939
main(opts);

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"swagger-parser": "^5.0.0",
5959
"swagger2openapi": "^2.11.16",
6060
"unicode-10.0.0": "^0.7.4",
61+
"update-notifier": "^2.5.0",
6162
"url-slug": "^2.0.0",
6263
"validate-npm-package-name": "^3.0.0",
6364
"yeoman-generator": "^3.1.1"

0 commit comments

Comments
 (0)