diff --git a/src/commands/preview.ts b/src/commands/preview.ts index a85868e..c72d60f 100644 --- a/src/commands/preview.ts +++ b/src/commands/preview.ts @@ -1,4 +1,3 @@ -import { config } from "../lib/config"; import { getFileSystemRepo } from "../lib/get-file-system-repo"; import { getQiitaApiInstance } from "../lib/get-qiita-api-instance"; import { getUrlAddress } from "../lib/getUrlAddress"; @@ -23,6 +22,6 @@ export const preview = async () => { startLocalChangeWatcher({ server, - watchPath: config.getItemsRootDir(), + watchPath: fileSystemRepo.getRootPath(), }); }; diff --git a/src/lib/file-system-repo.test.ts b/src/lib/file-system-repo.test.ts index a505e71..cd9e901 100644 --- a/src/lib/file-system-repo.test.ts +++ b/src/lib/file-system-repo.test.ts @@ -401,4 +401,12 @@ updated }); }); }); + + describe("getRootPath()", () => { + it("returns the root path", () => { + const dataRootDir = "./tmp"; + const instance = new FileSystemRepo({ dataRootDir }); + expect(instance.getRootPath()).toBe(`tmp/public`); + }); + }); }); diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 337d574..1fb2742 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -187,7 +187,7 @@ export class FileSystemRepo { await fs.mkdir(this.getRemotePath(), { recursive: true }); } - private getRootPath() { + public getRootPath() { const subdir = "public"; return path.join(this.dataRootDir, subdir); } diff --git a/src/server/app.ts b/src/server/app.ts index def04db..c1ea01e 100644 --- a/src/server/app.ts +++ b/src/server/app.ts @@ -65,7 +65,9 @@ export function startLocalChangeWatcher({ watchPath: string; }) { const wsServer = new WebSocketServer({ server }); - const watcher = chokidar.watch(watchPath); + const watcher = chokidar.watch(watchPath, { + ignored: ["**/.remote/**"], + }); watcher.on("change", () => { wsServer.clients.forEach((client) => { if (client.readyState === WebSocket.OPEN) {