11
2- import fs from 'fs-extra' ;
2+ import fsp from 'node:fs/promises' ;
3+ import fs from 'node:fs' ;
34import { glob } from 'glob' ;
45import mime from 'mime-types' ;
56import path from 'path' ;
@@ -10,17 +11,26 @@ export default class LocalFileSystem implements FileSystem
1011{
1112 copy ( source : string , destination : string ) : Promise < void >
1213 {
13- return fs . copy ( source , destination , { overwrite : true } ) ;
14+ return fsp . cp ( source , destination , { recursive : true , force : true } ) ;
1415 }
1516
1617 delete ( location : string ) : Promise < void >
1718 {
18- return fs . remove ( location ) ;
19+ return fsp . rm ( location , { recursive : true , force : true } ) ;
1920 }
2021
21- exists ( location : string ) : Promise < boolean >
22+ async exists ( location : string ) : Promise < boolean >
2223 {
23- return fs . exists ( location ) ;
24+ try
25+ {
26+ await fsp . stat ( location ) ;
27+
28+ return true ;
29+ }
30+ catch
31+ {
32+ return false ;
33+ }
2434 }
2535
2636 isAbsolute ( location : string ) : boolean
@@ -64,7 +74,7 @@ export default class LocalFileSystem implements FileSystem
6474
6575 read ( location : string ) : Promise < Buffer >
6676 {
67- return fs . readFile ( location ) ;
77+ return fsp . readFile ( location ) ;
6878 }
6979
7080 resolve ( location : string ) : string
@@ -100,6 +110,6 @@ export default class LocalFileSystem implements FileSystem
100110
101111 fs . mkdirSync ( directory , { recursive : true } ) ;
102112
103- return fs . writeFile ( location , content ) ;
113+ return fsp . writeFile ( location , content ) ;
104114 }
105115}
0 commit comments