Reject empty launchCwd values at runtime startup
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
60e9c8c00b
commit
dcb44cb729
2 files changed
+22
No files matched your search
@@ -236,6 +236,24 @@ describe("runtimeApiServer", () => {
|
||||
).rejects.toThrow("Invalid launchCwd does not exist");
|
||||
});
|
||||
|
||||
it("rejects startup when launchCwd is empty", async () => {
|
||||
await expect(
|
||||
startRuntimeApiServer({
|
||||
port: 0,
|
||||
launchCwd: "",
|
||||
}),
|
||||
).rejects.toThrow("Invalid launchCwd must be a non-empty path");
|
||||
});
|
||||
|
||||
it("rejects startup when launchCwd is not a string", async () => {
|
||||
await expect(
|
||||
startRuntimeApiServer({
|
||||
port: 0,
|
||||
launchCwd: 123 as unknown as string,
|
||||
}),
|
||||
).rejects.toThrow("Invalid launchCwd must be a non-empty path");
|
||||
});
|
||||
|
||||
it("rejects startup when launchCwd is not a directory", async () => {
|
||||
const tempDir = mkdtempSync(path.join(os.tmpdir(), "t3-launch-cwd-file-"));
|
||||
const filePath = path.join(tempDir, "launch.txt");
|
||||
|
||||
@@ -284,6 +284,10 @@ async function runTerminalCommand(
|
||||
}
|
||||
|
||||
function resolveExistingDirectory(targetPath: string, label: string): string {
|
||||
if (typeof targetPath !== "string" || targetPath.trim().length === 0) {
|
||||
throw new Error(`${label} must be a non-empty path.`);
|
||||
}
|
||||
|
||||
const candidate = path.resolve(targetPath);
|
||||
let stats: fs.Stats;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user