fix(gateway): watch nested source directories

This commit is contained in:
Peter Steinberger
2026-04-05 22:05:25 +01:00
parent aa464f8573
commit 52146f8803
2 changed files with 58 additions and 6 deletions

View File

@@ -1,4 +1,7 @@
import { EventEmitter } from "node:events";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { runNodeWatchedPaths } from "../../scripts/run-node.mjs";
import { runWatchMain } from "../../scripts/watch-node.mjs";
@@ -32,10 +35,13 @@ const createWatchHarness = () => {
describe("watch-node script", () => {
it("wires chokidar watch to run-node with watched source/config paths", async () => {
const { child, spawn, watcher, createWatcher, fakeProcess } = createWatchHarness();
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-watch-node-"));
fs.mkdirSync(path.join(cwd, "src", "infra"), { recursive: true });
fs.mkdirSync(path.join(cwd, "extensions", "voice-call"), { recursive: true });
const runPromise = runWatchMain({
args: ["gateway", "--force"],
cwd: "/tmp/openclaw",
cwd,
createWatcher,
env: { PATH: "/usr/bin" },
now: () => 1700000000000,
@@ -54,6 +60,10 @@ describe("watch-node script", () => {
expect(watchPaths).toContain("extensions");
expect(watchPaths).toContain("tsdown.config.ts");
expect(watchOptions.ignoreInitial).toBe(true);
expect(watchOptions.ignored("src")).toBe(false);
expect(watchOptions.ignored("src/infra")).toBe(false);
expect(watchOptions.ignored("extensions")).toBe(false);
expect(watchOptions.ignored("extensions/voice-call")).toBe(false);
expect(watchOptions.ignored("src/infra/watch-node.test.ts")).toBe(true);
expect(watchOptions.ignored("src/infra/watch-node.test.tsx")).toBe(true);
expect(watchOptions.ignored("src/infra/watch-node-test-helpers.ts")).toBe(true);
@@ -70,7 +80,7 @@ describe("watch-node script", () => {
"/usr/local/bin/node",
["scripts/run-node.mjs", "gateway", "--force"],
expect.objectContaining({
cwd: "/tmp/openclaw",
cwd,
stdio: "inherit",
env: expect.objectContaining({
PATH: "/usr/bin",