Skip to content

Commit a59841b

Browse files
authored
Fix race conditions with my-ts-node.sh (#2030)
If two my-ts-node scripts run at same time there were bad races ## Checklist - [ ] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [ ] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [ ] I have not broken the cheatsheet
1 parent 8e5a5b7 commit a59841b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/common/scripts/my-ts-node.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { build } from "esbuild";
88
import { existsSync, mkdirSync, rmdirSync } from "node:fs";
99
import { fileURLToPath } from "node:url";
1010
import { dirname, join } from "node:path";
11+
import { randomBytes } from "node:crypto";
1112

1213
/**
1314
* Run a command with arguments and return a child process
@@ -30,7 +31,12 @@ function runCommand(command, args, extraEnv = {}) {
3031
* @param {string} baseDir
3132
*/
3233
function createTempDirectory(baseDir) {
33-
const tempDir = join(baseDir, "out/my-ts-node-tmp");
34+
const tempDir = join(
35+
baseDir,
36+
"out",
37+
"my-ts-node-tmp",
38+
randomBytes(16).toString("hex"),
39+
);
3440
if (!existsSync(tempDir)) {
3541
mkdirSync(tempDir, { recursive: true });
3642
}

0 commit comments

Comments
 (0)