Skip to content

Commit f2f43a3

Browse files
committed
Lazy import update code
1 parent 3720c21 commit f2f43a3

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/commands/root.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { verbosityToLevel } from "../services/output/log/level.js";
55
import { println } from "../services/output/print.js";
66
import { reportErrorAndExit } from "../services/output/report.js";
77
import { sprint } from "../services/output/sprint.js";
8-
import { warnIfUpdateAvailable } from "../services/output/update.js";
8+
import { shouldCheckForUpdate } from "../services/output/update.js";
99
import { sortBySimilar } from "../services/util/collection.js";
1010
import { isNil } from "../services/util/is.js";
1111

@@ -64,7 +64,10 @@ export const run: Run<RootArgs> = async (parent, args): Promise<void> => {
6464
process.env["GGT_LOG_LEVEL"] = verbosityToLevel(args["--verbose"]).toString();
6565
}
6666

67-
await warnIfUpdateAvailable(ctx);
67+
if (await shouldCheckForUpdate(ctx)) {
68+
const { warnIfUpdateAvailable } = await import("../services/output/update.js");
69+
await warnIfUpdateAvailable(ctx);
70+
}
6871

6972
let commandName = args._.shift();
7073
if (isNil(commandName)) {

src/services/output/update.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ export const shouldCheckForUpdate = async (ctx: Context): Promise<boolean> => {
6060
*/
6161
export const warnIfUpdateAvailable = async (ctx: Context): Promise<void> => {
6262
try {
63-
const shouldCheck = await shouldCheckForUpdate(ctx);
64-
if (!shouldCheck) {
65-
return;
66-
}
67-
6863
await fs.outputFile(path.join(config.cacheDir, "last-update-check"), String(Date.now()));
6964

7065
const tags = await getDistTags(ctx);

0 commit comments

Comments
 (0)