fix: check workdir before spawn (#221)
The workdir used to spawn a agent command is provide by the agent tool, we need to ensure its existence and fallback to process.cwd when not. fix #212
This commit is contained in:
@@ -204,11 +204,20 @@ async function execCommand(
|
|||||||
runInSandbox: boolean,
|
runInSandbox: boolean,
|
||||||
abortSignal?: AbortSignal,
|
abortSignal?: AbortSignal,
|
||||||
): Promise<ExecCommandSummary> {
|
): Promise<ExecCommandSummary> {
|
||||||
|
let { workdir } = execInput;
|
||||||
|
if (workdir) {
|
||||||
|
try {
|
||||||
|
await access(workdir);
|
||||||
|
} catch (e) {
|
||||||
|
log(`EXEC workdir=${workdir} not found, use process.cwd() instead`);
|
||||||
|
workdir = process.cwd();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isLoggingEnabled()) {
|
if (isLoggingEnabled()) {
|
||||||
if (applyPatchCommand != null) {
|
if (applyPatchCommand != null) {
|
||||||
log("EXEC running apply_patch command");
|
log("EXEC running apply_patch command");
|
||||||
} else {
|
} else {
|
||||||
const { cmd, workdir, timeoutInMillis } = execInput;
|
const { cmd, timeoutInMillis } = execInput;
|
||||||
// Seconds are a bit easier to read in log messages and most timeouts
|
// Seconds are a bit easier to read in log messages and most timeouts
|
||||||
// are specified as multiples of 1000, anyway.
|
// are specified as multiples of 1000, anyway.
|
||||||
const timeout =
|
const timeout =
|
||||||
|
|||||||
Reference in New Issue
Block a user