Skip to content

Commit

Permalink
Add update notifications in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
bokub committed Jun 14, 2021
1 parent 861b759 commit 04ddfa0
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 289 deletions.
15 changes: 15 additions & 0 deletions bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import meow, { IsRequiredPredicate } from 'meow';
import { auth } from './auth';
import { daily, loadCurve, maxPower, MeteringFlags } from './metering';
import chalk from 'chalk';
import updateNotifier from 'update-notifier';

import * as pkg from '../package.json';

function exit(e: Error) {
if (e.message) {
Expand Down Expand Up @@ -71,6 +74,18 @@ const meteringFlags: MeteringFlags = {
output: cli.flags.output || null,
};

const notifier = updateNotifier({ pkg });
notifier.notify({
message:
'Mise à jour disponible: ' +
chalk.dim('{currentVersion}') +
chalk.reset(' → ') +
chalk.green('{latestVersion}') +
' \nLancez ' +
chalk.cyan('npm i -g linky') +
' pour mettre à jour',
});

switch (cli.input[0]) {
case authCommand:
try {
Expand Down
Loading

0 comments on commit 04ddfa0

Please sign in to comment.