Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fix: prevent mkdir race condition on cache directory (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: hiroki osame <[email protected]>
  • Loading branch information
kamsar and privatenumber authored Jun 24, 2022
1 parent 7348ce3 commit 6614d69
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/transform/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class FileCache extends Map<string, TransformResult> {
constructor() {
super();

if (!fs.existsSync(this.cacheDirectory)) {
fs.mkdirSync(this.cacheDirectory);
}
// Handles race condition if multiple tsx instances are running (#22)
fs.mkdirSync(this.cacheDirectory, { recursive: true });

this.cacheFiles = fs.readdirSync(this.cacheDirectory).map((fileName) => {
const [time, key] = fileName.split('-');
Expand Down

0 comments on commit 6614d69

Please sign in to comment.