Skip to content

Commit

Permalink
Add update notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqu committed Jan 17, 2020
1 parent a0530c8 commit dab0775
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@types/jest": "^24.0.18",
"@types/jsonwebtoken": "^8.3.4",
"@types/node": "^12.7.5",
"@types/update-notifier": "^2.5.0",
"@types/url-join": "^4.0.0",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^2.3.0",
Expand Down Expand Up @@ -68,6 +69,7 @@
"mask-json": "^1.0.3",
"strip-ansi": "^6.0.0",
"ts-dedent": "^1.1.0",
"update-notifier": "^4.0.0",
"url-join": "^4.0.1",
"winston": "^3.2.1"
}
Expand Down
16 changes: 14 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
#!/usr/bin/env node
import commander from "commander";
import updateNotifier from "update-notifier";

import { defaults } from "./config/defaults";
import { bin, version } from "../package.json";
import { bin, name, version } from "../package.json";
import { connect, ConnectOptions } from "./commands/connect";
import { login } from "./commands/login";
import { commandRunner } from "./util/command";
import { activateVerbose } from "./util/env";
import logger from "./util/logger";

const program = new commander.Command();
function beforeCommand(): void {
const un = updateNotifier({
pkg: {
name,
version
}
});
un.notify();
}

function createCollector(): (arg1: string, arg2: string[]) => string[] {
let cleared = false;
Expand All @@ -27,6 +36,8 @@ function createCollector(): (arg1: string, arg2: string[]) => string[] {
return collectionValue;
}

const program = new commander.Command();

program
.name(Object.keys(bin)[0])
.version(version);
Expand Down Expand Up @@ -67,4 +78,5 @@ program.on("command:*", () => {
program.outputHelp();
});

beforeCommand();
program.parseAsync(process.argv);

0 comments on commit dab0775

Please sign in to comment.