aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/create-turbo/src/utils/notifyUpdate.ts
blob: e1dadc0cf92e1254c28d6ddfac2e4034e9c2b859 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import chalk from "chalk";
import checkForUpdate from "update-check";

import cliPkgJson from "../../package.json";

const update = checkForUpdate(cliPkgJson).catch(() => null);

export default async function notifyUpdate(): Promise<void> {
  try {
    const res = await update;
    if (res?.latest) {
      console.log();
      console.log(
        chalk.yellow.bold("A new version of `create-turbo` is available!")
      );
      console.log();
    }
    process.exit();
  } catch (_e: any) {
    // ignore error
  }
}