mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 09:10:20 +00:00
fix(gateway): watch nested source directories
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user