fix(daemon): create parent directory when packing bundle to missing path (#258)

This commit is contained in:
Ege authored and GitHub committed 2026-09-30 19:21:09 -07:00
1 parent 3691134c5b
commit 1347d825c3
2 files changed
+16

No files matched your search

@@ -25,6 +25,11 @@ export async function pack(stagingDir: string, outputPath: string): Promise<stri
throw new Error("Output path must end with .rigbundle");
}
const outDir = nodePath.dirname(outputPath);
if (outDir && !fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true });
}
// Collect all files in deterministic order (alphabetical)
const allFiles = walkFilesSync(stagingDir).sort();
@@ -64,6 +64,17 @@ describe("Bundle archive", () => {
return staging;
}
it("pack creates parent directory if it does not exist", async () => {
const staging = createStaging();
const nestedOut = path.join(tmpDir, "missing", "sub", "test.rigbundle");
const hash = await pack(staging, nestedOut);
expect(fs.existsSync(nestedOut)).toBe(true);
expect(fs.existsSync(`${nestedOut}.sha256`)).toBe(true);
expect(hash).toMatch(/^[a-f0-9]{64}$/);
});
// T1: Pack creates valid tar.gz
it("pack creates valid tar.gz file", async () => {
const staging = createStaging();