fix(codex): harden windows light install
This commit is contained in:
@@ -18,6 +18,11 @@ const runtimes = [
|
||||
packageRoot: join(repoPackagesRoot, "ast-grep-mcp"),
|
||||
requiredOutputs: ["dist/cli.js"],
|
||||
},
|
||||
{
|
||||
label: "git-bash-mcp",
|
||||
packageRoot: join(repoPackagesRoot, "git-bash-mcp"),
|
||||
requiredOutputs: ["dist/cli.js"],
|
||||
},
|
||||
];
|
||||
|
||||
for (const runtime of runtimes) {
|
||||
@@ -25,13 +30,18 @@ for (const runtime of runtimes) {
|
||||
}
|
||||
|
||||
function buildRuntime(runtime) {
|
||||
if (hasBundledDist(runtime)) {
|
||||
console.log(`Using bundled ${runtime.label} dist`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!existsSync(join(runtime.packageRoot, "package.json"))) {
|
||||
assertBundledDist(runtime);
|
||||
console.log(`Using bundled ${runtime.label} dist`);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = spawnSync("bun", ["run", "build"], {
|
||||
const result = spawnSync("npm", ["run", "build"], {
|
||||
cwd: runtime.packageRoot,
|
||||
stdio: "inherit",
|
||||
});
|
||||
@@ -39,6 +49,10 @@ function buildRuntime(runtime) {
|
||||
if (result.status !== 0) process.exit(result.status ?? 1);
|
||||
}
|
||||
|
||||
function hasBundledDist(runtime) {
|
||||
return runtime.requiredOutputs.every((output) => existsSync(join(runtime.packageRoot, output)));
|
||||
}
|
||||
|
||||
function assertBundledDist(runtime) {
|
||||
const missingOutputs = runtime.requiredOutputs.filter((output) => !existsSync(join(runtime.packageRoot, output)));
|
||||
if (missingOutputs.length === 0) return;
|
||||
|
||||
@@ -14,7 +14,7 @@ for (const workspace of workspaces) {
|
||||
if (typeof workspacePackageJson.scripts?.build !== "string") continue;
|
||||
|
||||
console.log(`Building ${workspace}`);
|
||||
const result = spawnSync("bun", ["run", "--cwd", workspace, "build"], {
|
||||
const result = spawnSync("npm", ["run", "--workspace", workspace, "build"], {
|
||||
cwd: root,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user