openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
31 lines (30 loc) • 1.21 kB
JavaScript
import process from "node:process";
//#region src/infra/package-local-overrides.worker.ts
const [configUrl, rootUrl, durabilityUrl, errorsUrl, rootDir, sourcePath, relativePath] = process.argv.slice(2);
if (!configUrl || !rootUrl || !durabilityUrl || !errorsUrl || !rootDir || !sourcePath || !relativePath) throw new Error("Local override publication requires its retained runtime and paths");
const { configureFsSafeNative } = await import(configUrl);
configureFsSafeNative({ mode: "require" });
const { root } = await import(rootUrl);
const { publishFileExclusive } = await import(durabilityUrl);
const { FsSafeError } = await import(errorsUrl);
const packageFs = await root(rootDir, {
hardlinks: "reject",
symlinks: "reject"
});
const source = await packageFs.open(sourcePath);
try {
await publishFileExclusive({
sourcePath: source.realPath,
targetPath: await packageFs.resolve(relativePath),
expectedSourceIdentity: source.exactIdentity,
strategy: "rename-noreplace"
});
process.stdout.write("moved");
} catch (e) {
if (e instanceof FsSafeError && e.details?.targetCreated === true) process.stdout.write("moved");
throw e;
} finally {
await source.handle.close();
}
//#endregion
export {};