Skip to content

Commit

Permalink
feat(cli): add update-notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
wadackel committed Dec 22, 2020
1 parent ff3264c commit 84fe911
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"prettier": "^2.2.0",
"strip-ansi": "^6.0.0",
"type-fest": "^0.20.2",
"update-notifier": "^5.0.1",
"validator": "^13.1.17",
"yargs": "^16.1.1"
},
Expand All @@ -67,6 +68,7 @@
"@types/node-emoji": "^1.8.1",
"@types/opener": "^1.4.0",
"@types/prettier": "^2.1.5",
"@types/update-notifier": "^5.0.0",
"@types/validator": "^13.1.0",
"@types/yargs": "^15.0.10"
},
Expand Down
11 changes: 9 additions & 2 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import { Logger } from '@acot/logger';
import type { PackageJson } from 'type-fest';
import updateNotifier from 'update-notifier';
import { CLI } from './cli';
import { CommandContainer } from './command-container';
import { commands } from './commands';
Expand All @@ -10,8 +11,14 @@ import { commands } from './commands';

try {
const pkg = require('../package.json') as PackageJson;
const container = new CommandContainer(commands);
const cli = new CLI(pkg, logger, container);

updateNotifier({
pkg: pkg as any,
distTag: pkg.version?.includes('canary') ? 'canary' : 'latest',
}).notify();

const cli = new CLI(pkg, logger, new CommandContainer(commands));

process.exit(await cli.run(process.argv.slice(2)));
} catch (e) {
logger.error(e);
Expand Down

0 comments on commit 84fe911

Please sign in to comment.