Skip to content

Commit fb61d95

Browse files
committed
Make sure the .trigger dir exists before creating the dev.lock file
1 parent 8d55ae3 commit fb61d95

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/cli-v3/src/dev/lock.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "node:path";
22
import { readFile } from "../utilities/fileSystem.js";
33
import { tryCatch } from "@trigger.dev/core/utils";
44
import { logger } from "../utilities/logger.js";
5-
import { writeFile } from "node:fs/promises";
5+
import { mkdir, writeFile } from "node:fs/promises";
66
import { existsSync, unlinkSync } from "node:fs";
77
import { onExit } from "signal-exit";
88

@@ -76,7 +76,7 @@ export async function createLockFile(cwd: string) {
7676
}
7777

7878
// Now write the current pid to the lockfile
79-
await writeFile(lockFilePath, currentPid.toString());
79+
await writeFileAndEnsureDirExists(lockFilePath, currentPid.toString());
8080

8181
logger.debug("Lockfile created", { lockFilePath, currentPid });
8282

@@ -85,3 +85,9 @@ export async function createLockFile(cwd: string) {
8585
removeLockFile();
8686
};
8787
}
88+
89+
async function writeFileAndEnsureDirExists(filePath: string, data: string) {
90+
const dir = path.dirname(filePath);
91+
await mkdir(dir, { recursive: true });
92+
await writeFile(filePath, data);
93+
}

0 commit comments

Comments
 (0)