From a6b2967df86895fb5402d4aaa8dfa91417e4d1ab Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Thu, 7 Nov 2024 16:32:26 -0800 Subject: [PATCH] fix: account for chokidar v4 glob deprecation in source watching --- quartz/cli/handlers.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/quartz/cli/handlers.js b/quartz/cli/handlers.js index 5538152..01adc55 100644 --- a/quartz/cli/handlers.js +++ b/quartz/cli/handlers.js @@ -15,6 +15,7 @@ import { WebSocketServer } from "ws" import { randomUUID } from "crypto" import { Mutex } from "async-mutex" import { CreateArgv } from "./args.js" +import { globby } from "globby" import { exitIfCancel, escapePath, @@ -290,8 +291,8 @@ export async function handleBuild(argv) { } if (cleanupBuild) { - await cleanupBuild() console.log(chalk.yellow("Detected a source code change, doing a hard rebuild...")) + await cleanupBuild() } const result = await ctx.rebuild().catch((err) => { @@ -423,13 +424,12 @@ export async function handleBuild(argv) { ), ) console.log("hint: exit with ctrl+c") + const paths = await globby(["**/*.ts", "**/*.tsx", "**/*.scss", "package.json"]) chokidar - .watch(["**/*.ts", "**/*.tsx", "**/*.scss", "package.json"], { - ignoreInitial: true, - }) - .on("all", async () => { - build(clientRefresh) - }) + .watch(paths, { ignoreInitial: true }) + .on("add", () => build(clientRefresh)) + .on("change", () => build(clientRefresh)) + .on("unlink", () => build(clientRefresh)) } else { await build(() => {}) ctx.dispose()