Skip to content

Commit

Permalink
Avoid file locks + overwrites by using a temp file for HTML templates (
Browse files Browse the repository at this point in the history
…#1336)

* Avoid file locks + overwrites by using a temp file for HTML templates

This fixes #1331.

* refactor: Replace tempy with simple random number gen

* docs: Adding changeset

Co-authored-by: Ryan Christian <[email protected]>
  • Loading branch information
developit and rschristian authored Dec 24, 2022
1 parent 70d192f commit bea4f50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-dryers-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Temp files generated by `preact-cli` are now unique to a build, allowing for concurrent instances to run at the same time.
5 changes: 4 additions & 1 deletion packages/cli/src/lib/webpack/render-html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ module.exports = async function (config) {

// Unfortunately html-webpack-plugin expects a true file,
// so we'll create a temporary one.
const tmpDir = join(os.tmpdir(), 'preact-cli');
const tmpDir = join(
os.tmpdir(),
`preact-cli-${Math.floor(Math.random() * 100000)}`
);
if (!existsSync(tmpDir)) {
mkdirSync(tmpDir);
}
Expand Down

0 comments on commit bea4f50

Please sign in to comment.