Merge ac8c1f19bc into 09be5d45d5
This commit is contained in:
commit
31e6866a4a
@ -68,6 +68,20 @@ async function resolveRealpathSafe(inputPath: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derive working directory from a dist entrypoint path.
|
||||||
|
* E.g., /path/to/moltbot/dist/entry.js -> /path/to/moltbot
|
||||||
|
*/
|
||||||
|
function resolveWorkingDirectoryFromEntrypoint(entrypointPath: string): string | undefined {
|
||||||
|
const dir = path.dirname(entrypointPath);
|
||||||
|
const parts = dir.split(path.sep);
|
||||||
|
const distIndex = parts.lastIndexOf("dist");
|
||||||
|
if (distIndex > 0) {
|
||||||
|
return parts.slice(0, distIndex).join(path.sep);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function buildDistCandidates(...inputs: string[]): string[] {
|
function buildDistCandidates(...inputs: string[]): string[] {
|
||||||
const candidates: string[] = [];
|
const candidates: string[] = [];
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
@ -167,6 +181,7 @@ async function resolveCliProgramArguments(params: {
|
|||||||
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
||||||
return {
|
return {
|
||||||
programArguments: [nodePath, cliEntrypointPath, ...params.args],
|
programArguments: [nodePath, cliEntrypointPath, ...params.args],
|
||||||
|
workingDirectory: resolveWorkingDirectoryFromEntrypoint(cliEntrypointPath),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +201,7 @@ async function resolveCliProgramArguments(params: {
|
|||||||
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
||||||
return {
|
return {
|
||||||
programArguments: [bunPath, cliEntrypointPath, ...params.args],
|
programArguments: [bunPath, cliEntrypointPath, ...params.args],
|
||||||
|
workingDirectory: resolveWorkingDirectoryFromEntrypoint(cliEntrypointPath),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +210,7 @@ async function resolveCliProgramArguments(params: {
|
|||||||
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
const cliEntrypointPath = await resolveCliEntrypointPathForService();
|
||||||
return {
|
return {
|
||||||
programArguments: [execPath, cliEntrypointPath, ...params.args],
|
programArguments: [execPath, cliEntrypointPath, ...params.args],
|
||||||
|
workingDirectory: resolveWorkingDirectoryFromEntrypoint(cliEntrypointPath),
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If running under bun or another runtime that can execute TS directly
|
// If running under bun or another runtime that can execute TS directly
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user