fix: preserve gitbundle tool wrapper paths
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { chmod, cp, mkdir, readdir, readFile, rm, stat } from "node:fs/promises";
|
||||
import { chmod, cp, mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { AgentRunError } from "../common/errors.js";
|
||||
import { redactText } from "../common/redaction.js";
|
||||
@@ -193,6 +193,14 @@ function optionalNonEmpty(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
function shellSingleQuote(value: string): string {
|
||||
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
||||
}
|
||||
|
||||
function installedToolShim(sourcePath: string): string {
|
||||
return `#!/usr/bin/env sh\nexec ${shellSingleQuote(sourcePath)} "$@"\n`;
|
||||
}
|
||||
|
||||
async function prepareGitBundleTools(workspacePath: string, env: NodeJS.ProcessEnv): Promise<{ binPath?: string; event: JsonRecord }> {
|
||||
const sourceBinPath = path.join(workspacePath, "tools");
|
||||
const installedBinPath = optionalNonEmpty(env.AGENTRUN_RESOURCE_BIN_PATH);
|
||||
@@ -217,7 +225,7 @@ async function prepareGitBundleTools(workspacePath: string, env: NodeJS.ProcessE
|
||||
if (installedBinPath) {
|
||||
const targetPath = path.join(installedBinPath, entry.name);
|
||||
if (targetPath !== filePath) {
|
||||
await cp(filePath, targetPath, { force: true, dereference: false });
|
||||
await writeFile(targetPath, installedToolShim(filePath), "utf8");
|
||||
await chmod(targetPath, 0o755);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user