File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import path from "node:path";
2
2
import { readFile } from "../utilities/fileSystem.js" ;
3
3
import { tryCatch } from "@trigger.dev/core/utils" ;
4
4
import { logger } from "../utilities/logger.js" ;
5
- import { writeFile } from "node:fs/promises" ;
5
+ import { mkdir , writeFile } from "node:fs/promises" ;
6
6
import { existsSync , unlinkSync } from "node:fs" ;
7
7
import { onExit } from "signal-exit" ;
8
8
@@ -76,7 +76,7 @@ export async function createLockFile(cwd: string) {
76
76
}
77
77
78
78
// Now write the current pid to the lockfile
79
- await writeFile ( lockFilePath , currentPid . toString ( ) ) ;
79
+ await writeFileAndEnsureDirExists ( lockFilePath , currentPid . toString ( ) ) ;
80
80
81
81
logger . debug ( "Lockfile created" , { lockFilePath, currentPid } ) ;
82
82
@@ -85,3 +85,9 @@ export async function createLockFile(cwd: string) {
85
85
removeLockFile ( ) ;
86
86
} ;
87
87
}
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
+ }
You can’t perform that action at this time.
0 commit comments