Skip to content

Commit 5585de9

Browse files
eyelidlessnessnatemoo-re
authored andcommitted
Fix an issue with binary public file corruption (#110)
* Ensure head is rendered for SSG It seems the implementation was intended to achieve this sort of isolation the same way `docContext` is used. But the `useRef` version was basically just sending any children in `Head` into the memory hole on build. * Add another page just to validate that each page gets a new head context as expected * Fix an issue with binary public file corruption The previous behavior was reading binary files as strings, which was corrupting them on output
1 parent 5178817 commit 5585de9

File tree

1 file changed

+6
-2
lines changed
  • packages/microsite/src/utils

1 file changed

+6
-2
lines changed

packages/microsite/src/utils/fs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ export const copyFile = async (
4848
dest: string,
4949
{ transform }: CopyFileOpts = {}
5050
) => {
51-
let content = await fsp.readFile(src).then((res) => res.toString());
5251
if (transform) {
52+
let content = await fsp.readFile(src).then((res) => res.toString());
5353
content = await transform(content);
54+
await writeFile(dest, content);
55+
}
56+
else {
57+
await mkdir(dirname(dest));
58+
await fsp.copyFile(src, dest);
5459
}
55-
await writeFile(dest, content);
5660
};
5761

5862
export const copyDir = async (src: string, dest: string) => {

0 commit comments

Comments
 (0)