-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclaudeWorkerTestContext.mjs
More file actions
19 lines (18 loc) · 898 Bytes
/
Copy pathclaudeWorkerTestContext.mjs
File metadata and controls
19 lines (18 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as fs from "node:fs";
import * as path from "node:path";
export function resolveClaudeWorkerNodeModules(context, candidate, fallback) {
if (!candidate) return path.resolve(fallback);
if (!path.isAbsolute(candidate)) {
throw new Error("KAIZEN_CLAUDE_WORKER_NODE_MODULES must be an absolute path");
}
const resolved = path.resolve(candidate);
if (!fs.existsSync(resolved) || !fs.statSync(resolved).isDirectory()) {
throw new Error(`KAIZEN_CLAUDE_WORKER_NODE_MODULES is not an existing directory: ${resolved}`);
}
const physical = fs.realpathSync(resolved);
const relative = path.relative(fs.realpathSync(context.root), physical);
if (relative === "" || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
throw new Error("KAIZEN_CLAUDE_WORKER_NODE_MODULES must be beneath KAIZEN_TEST_TEMP_ROOT");
}
return physical;
}