mirror of
https://github.com/morluto/rea.git
synced 2026-11-29 23:58:41 +00:00
refactor(cli): share compiled runtime checks with the session worker (#14557)
This commit is contained in:
1 parent
825fd0a19a
commit
0bbdbeaedf
8 files changed
+72
-91
No files matched your search
@@ -1,8 +1,11 @@
|
||||
import { Readable, Writable } from "node:stream";
|
||||
import { access } from "node:fs/promises";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
compiledRuntimeExists,
|
||||
missingCompiledRuntimeMessage,
|
||||
} from "../../../scripts/lib/cli-compiled-runtime.mjs";
|
||||
import { prepareCliProcessEnvironment } from "../../../scripts/lib/cli-process-environment.mjs";
|
||||
import { withVerifierCleanup } from "../../../scripts/lib/verifier-cleanup.mjs";
|
||||
import {
|
||||
@@ -35,10 +38,8 @@ prepareCliProcessEnvironment(
|
||||
process.platform,
|
||||
packageJson.version,
|
||||
);
|
||||
if (!(await compiledRuntimeExists(runtimeFiles))) {
|
||||
process.stderr.write(
|
||||
`REA's compiled runtime is missing. Run \`npm ci && npm run build:cached\` in ${packageRoot} to install dependencies and build REA, then restart it. If this is an installed package, reinstall rea-agents.\n`,
|
||||
);
|
||||
if (!(await compiledRuntimeExists(packageRoot, runtimeFiles))) {
|
||||
process.stderr.write(missingCompiledRuntimeMessage(packageRoot));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -253,24 +254,3 @@ function captureWrite(chunks) {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
async function compiledRuntimeExists(paths) {
|
||||
for (const path of paths) {
|
||||
try {
|
||||
await access(resolve(packageRoot, path));
|
||||
} catch (cause) {
|
||||
if (isMissing(cause)) return false;
|
||||
throw cause;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isMissing(cause) {
|
||||
return (
|
||||
typeof cause === "object" &&
|
||||
cause !== null &&
|
||||
"code" in cause &&
|
||||
cause.code === "ENOENT"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user