@@ -7,17 +7,17 @@ import { lookpath } from 'lookpath';
7
7
8
8
import { isErrorLike } from './error' ;
9
9
10
- export const statFile = promisify ( fs . stat ) ;
11
- export const readFile = promisify ( fs . readFile ) ;
12
- export const readDir = promisify ( fs . readdir ) ;
13
- export const readLink = promisify ( fs . readlink ) ;
14
- export const deleteFile = promisify ( fs . unlink ) ;
15
- export const checkAccess = promisify ( fs . access ) ;
16
- export const chmod = promisify ( fs . chmod ) ;
17
- export const mkDir = promisify ( fs . mkdir ) ;
18
- export const writeFile = promisify ( fs . writeFile ) ;
19
- export const renameFile = promisify ( fs . rename ) ;
20
- export const copyFile = promisify ( fs . copyFile ) ;
10
+ export const statFile = fs . promises . stat ;
11
+ export const readFile = fs . promises . readFile ;
12
+ export const readDir = fs . promises . readdir ;
13
+ export const readLink = fs . promises . readlink ;
14
+ export const deleteFile = fs . promises . unlink ;
15
+ export const deleteFolder = promisify ( rimraf ) ;
16
+ export const checkAccess = fs . promises . access ;
17
+ export const chmod = fs . promises . chmod ;
18
+ export const mkDir = fs . promises . mkdir ;
19
+ export const writeFile = fs . promises . writeFile ;
20
+ export const copyFile = fs . promises . copyFile ;
21
21
22
22
export const copyRecursive = async ( from : string , to : string ) => {
23
23
// fs.cp is only available in Node 16.7.0+
@@ -51,8 +51,6 @@ export const getRealPath = async (targetPath: string): Promise<string | undefine
51
51
}
52
52
} ;
53
53
54
- export const deleteFolder = promisify ( rimraf ) ;
55
-
56
54
export const ensureDirectoryExists = ( path : string ) =>
57
55
checkAccess ( path ) . catch ( ( ) => mkDir ( path , { recursive : true } ) ) ;
58
56
@@ -75,7 +73,7 @@ export const createTmp = (options: tmp.Options = {}) => new Promise<{
75
73
76
74
export const moveFile = async ( oldPath : string , newPath : string ) => {
77
75
try {
78
- await renameFile ( oldPath , newPath ) ;
76
+ await fs . promises . rename ( oldPath , newPath ) ;
79
77
} catch ( e ) {
80
78
if ( isErrorLike ( e ) && e . code === 'EXDEV' ) {
81
79
// Cross-device - can't rename files across partions etc.
0 commit comments