@nuxt/cli
Version:
Nuxt CLI
35 lines (34 loc) • 1.59 kB
JavaScript
import { f as debug } from "./startup-clock-SyYej6uN.mjs";
import { checkForUpdate, deferNudge, isUpdateCheckEnabled } from "./update-check-DlXT1ean.mjs";
// src/utils/update.ts
/**
* Resolve the installed and latest Nuxt versions, returning nothing when the
* project is already current or when anything at all goes wrong (an offline
* user should never see an error from a check they did not ask for).
*/
async function checkForNuxtUpdate(cwd) {
try {
const current = await import("./versions-DysBt-5w.mjs").then((n) => n.i).then(({ getNuxtVersion }) => getNuxtVersion(cwd)).catch(() => void 0);
return await checkForUpdate("nuxt", current);
} catch (error) {
debug("Failed to check for Nuxt updates:", error);
return;
}
}
const UNNUDGED_COMMANDS = /* @__PURE__ */ new Set(["upgrade", "init"]);
/**
* Check for a newer Nuxt release without blocking the command, deferring the
* nudge to process exit so it can never interleave with the command's own
* output (including the long-lived `dev` server's banner and logs).
*
* `upgrade` is excluded because the installed version is read when the command
* starts, so a nudge would still be pending once the upgrade has succeeded.
* `init` is excluded because the version it would report belongs to whatever
* directory the user happened to scaffold from, not to the new project.
*/
async function scheduleUpdateNudge(cwd, command) {
if (command && UNNUDGED_COMMANDS.has(command) || !isUpdateCheckEnabled()) return;
const update = await checkForNuxtUpdate(cwd);
if (update) deferNudge(update);
}
export { scheduleUpdateNudge };