Skip to content

Commit

Permalink
Fix an issue with binary public file corruption (#110)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eyelidlessness authored and natemoo-re committed Jan 29, 2021
1 parent 5178817 commit 5585de9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/microsite/src/utils/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ export const copyFile = async (
dest: string,
{ transform }: CopyFileOpts = {}
) => {
let content = await fsp.readFile(src).then((res) => res.toString());
if (transform) {
let content = await fsp.readFile(src).then((res) => res.toString());
content = await transform(content);
await writeFile(dest, content);
}
else {
await mkdir(dirname(dest));
await fsp.copyFile(src, dest);
}
await writeFile(dest, content);
};

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

0 comments on commit 5585de9

Please sign in to comment.