-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ffda68
commit 06d9e08
Showing
2 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
yarn-project/noir-compiler/src/compile/noir/file-manager/nodejs-file-manager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { existsSync } from 'node:fs'; | ||
import * as fs from 'node:fs/promises'; | ||
|
||
import { FileManager } from './file-manager.js'; | ||
|
||
/** | ||
* Creates a new FileManager instance based on nodejs fs | ||
* @param dataDir - where to store files | ||
*/ | ||
export function createNodejsFileManager(dataDir: string): FileManager { | ||
return new FileManager( | ||
{ | ||
...fs, | ||
...{ | ||
// ExistsSync is not available in the fs/promises module | ||
existsSync, | ||
// This is added here because the node types are not compatible with the FileSystem type for mkdir | ||
// Typescripts tries to use a different variant of the function that is not the one that has the optional options. | ||
mkdir: async ( | ||
dir: string, | ||
opts?: { | ||
/** | ||
* Traverse child directories | ||
*/ | ||
recursive: boolean; | ||
}, | ||
) => { | ||
await fs.mkdir(dir, opts); | ||
}, | ||
}, | ||
}, | ||
dataDir, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters