File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as fs from "fs" ;
2
+ import { promisify } from "util" ;
2
3
3
4
import { FileSystem } from "./fileSystem" ;
4
5
6
+ const readFile = promisify ( fs . readFile ) ;
7
+ const writeFile = promisify ( fs . writeFile ) ;
8
+
5
9
export const fsFileSystem : FileSystem = {
6
10
fileExists : async ( filePath : string ) => {
7
11
try {
@@ -12,14 +16,14 @@ export const fsFileSystem: FileSystem = {
12
16
} ,
13
17
readFile : async ( filePath : string ) => {
14
18
try {
15
- return ( await fs . promises . readFile ( filePath ) ) . toString ( ) ;
19
+ return ( await readFile ( filePath ) ) . toString ( ) ;
16
20
} catch ( error ) {
17
21
return error ;
18
22
}
19
23
} ,
20
24
writeFile : async ( filePath : string , contents : string ) => {
21
25
try {
22
- return fs . promises . writeFile ( filePath , contents ) ;
26
+ return writeFile ( filePath , contents ) ;
23
27
} catch ( error ) {
24
28
return error ;
25
29
}
You can’t perform that action at this time.
0 commit comments