Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ type Options = {

async function main() {
// Start a version check in the background
const cliVersionCheckPromise = checkLatestVersion();
// unhandled promise rejection can happen even without the `await`
// so we need a `catch` here.
const cliVersionCheckPromise = checkLatestVersion().catch(() => ({
latestVersion: "unknown",
currentVersion: "unknown",
isNewerAvailable: false,
}));

// Must load tokens and config before anything else
await authStore.initialize();
Expand Down Expand Up @@ -91,19 +97,15 @@ async function main() {
}
}

try {
const { latestVersion, currentVersion, isNewerAvailable } =
await cliVersionCheckPromise;
const { latestVersion, currentVersion, isNewerAvailable } =
await cliVersionCheckPromise;

if (isNewerAvailable) {
console.info(
`A new version of the CLI is available: ${chalk.yellow(
currentVersion,
)} -> ${chalk.green(latestVersion)}. Update to ensure you have the latest features and bug fixes.`,
);
}
} catch {
// Ignore errors
if (isNewerAvailable) {
console.info(
`A new version of the CLI is available: ${chalk.yellow(
currentVersion,
)} -> ${chalk.green(latestVersion)}. Update to ensure you have the latest features and bug fixes.`,
);
}

if (debug) {
Expand Down
1 change: 0 additions & 1 deletion packages/cli/utils/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export async function checkLatest() {

const latestVersion = await getLatestVersionFromNpm(packageName);
const isNewerAvailable = gt(latestVersion, currentVersion);

return {
currentVersion,
latestVersion,
Expand Down