Skip to content

Commit bea4f50

Browse files
Avoid file locks + overwrites by using a temp file for HTML templates (#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]>
1 parent 70d192f commit bea4f50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/violet-dryers-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-cli': patch
3+
---
4+
5+
Temp files generated by `preact-cli` are now unique to a build, allowing for concurrent instances to run at the same time.

packages/cli/src/lib/webpack/render-html-plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ module.exports = async function (config) {
4545

4646
// Unfortunately html-webpack-plugin expects a true file,
4747
// so we'll create a temporary one.
48-
const tmpDir = join(os.tmpdir(), 'preact-cli');
48+
const tmpDir = join(
49+
os.tmpdir(),
50+
`preact-cli-${Math.floor(Math.random() * 100000)}`
51+
);
4952
if (!existsSync(tmpDir)) {
5053
mkdirSync(tmpDir);
5154
}

0 commit comments

Comments
 (0)