diff options
Diffstat (limited to 'packages/turbo-codemod/src/utils/notifyUpdate.ts')
| -rw-r--r-- | packages/turbo-codemod/src/utils/notifyUpdate.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/turbo-codemod/src/utils/notifyUpdate.ts b/packages/turbo-codemod/src/utils/notifyUpdate.ts new file mode 100644 index 0000000..634ffd8 --- /dev/null +++ b/packages/turbo-codemod/src/utils/notifyUpdate.ts @@ -0,0 +1,35 @@ +import chalk from "chalk"; +import checkForUpdate from "update-check"; + +import cliPkgJson from "../../package.json"; +import getWorkspaceImplementation from "./getPackageManager"; + +const update = checkForUpdate(cliPkgJson).catch(() => null); + +export default async function notifyUpdate(): Promise<void> { + try { + const res = await update; + if (res?.latest) { + const ws = getWorkspaceImplementation(); + + console.log(); + console.log( + chalk.yellow.bold("A new version of `@turbo/codemod` is available!") + ); + console.log( + "You can update by running: " + + chalk.cyan( + ws === "yarn" + ? "yarn global add @turbo/codemod" + : ws === "pnpm" + ? "pnpm i -g @turbo/codemod" + : "npm i -g @turbo/codemod" + ) + ); + console.log(); + } + process.exit(); + } catch (_e: any) { + // ignore error + } +} |
