Skip to content

Commit 077b78d

Browse files
author
Zayd
committed
fix(build): replace any stale desktop artifact destination before copying
On a reused --target dir output, copyDesktopBuildArtifacts only removed the destination for staged directories, so a staged file sharing a name with an earlier output directory failed in fs.cp with ERR_FS_CP_NON_DIR_TO_DIR. Remove the destination unconditionally so either type replaces the other.
1 parent 6948899 commit 077b78d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎scripts/build-desktop-artifact.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,10 @@ it.effect("preserves packaged app directories from the dir target", () =>
17701770
const filesOnly = yield* copyDesktopBuildArtifacts(stage, path.join(root, "files-only"));
17711771
assert.deepEqual(filesOnly, [path.join(root, "files-only", "builder-debug.yml")]);
17721772
assert.isFalse(yield* fs.exists(path.join(root, "files-only", "mac-arm64")));
1773+
yield* fs.remove(path.join(stage, "mac-arm64"), { recursive: true });
1774+
yield* fs.writeFileString(path.join(stage, "mac-arm64"), "flattened");
1775+
yield* copyDesktopBuildArtifacts(stage, output, true);
1776+
assert.equal(yield* fs.readFileString(path.join(output, "mac-arm64")), "flattened");
17731777
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
17741778
);
17751779

‎scripts/build-desktop-artifact.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,9 +4101,10 @@ export const copyDesktopBuildArtifacts = Effect.fn("copyDesktopBuildArtifacts")(
41014101
continue;
41024102

41034103
const to = path.join(outputDir, entry);
4104-
if (stat.type === "Directory") {
4105-
yield* fs.remove(to, { recursive: true, force: true });
4106-
}
4104+
// Replace whatever a reused output dir already holds at this path. fs.cp refuses to
4105+
// overwrite a directory with a file or a file with a directory, and only merges into
4106+
// an existing directory, so a stale entry of either type must go first.
4107+
yield* fs.remove(to, { recursive: true, force: true });
41074108
yield* Effect.tryPromise(() =>
41084109
NodeFSP.cp(from, to, {
41094110
recursive: true,

0 commit comments

Comments
 (0)