Skip to content

Commit

Permalink
Fix race conditions with my-ts-node.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
pokey committed Nov 14, 2023
1 parent 8e5a5b7 commit 5814781
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/common/scripts/my-ts-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { build } from "esbuild";
import { existsSync, mkdirSync, rmdirSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import { randomBytes } from "node:crypto";

/**
* Run a command with arguments and return a child process
Expand All @@ -30,7 +31,12 @@ function runCommand(command, args, extraEnv = {}) {
* @param {string} baseDir
*/
function createTempDirectory(baseDir) {
const tempDir = join(baseDir, "out/my-ts-node-tmp");
const tempDir = join(
baseDir,
"out",
"my-ts-node-tmp",
randomBytes(16).toString("hex"),
);
if (!existsSync(tempDir)) {
mkdirSync(tempDir, { recursive: true });
}
Expand Down

0 comments on commit 5814781

Please sign in to comment.