@@ -15,6 +15,7 @@ const {
15
15
MathMin,
16
16
NumberIsSafeInteger,
17
17
Promise,
18
+ PromisePrototypeFinally,
18
19
PromiseResolve,
19
20
Symbol,
20
21
Uint8Array,
@@ -431,7 +432,7 @@ async function rename(oldPath, newPath) {
431
432
432
433
async function truncate ( path , len = 0 ) {
433
434
const fd = await open ( path , 'r+' ) ;
434
- return ftruncate ( fd , len ) . finally ( fd . close ) ;
435
+ return PromisePrototypeFinally ( ftruncate ( fd , len ) , fd . close ) ;
435
436
}
436
437
437
438
async function ftruncate ( handle , len = 0 ) {
@@ -559,7 +560,7 @@ async function lchmod(path, mode) {
559
560
throw new ERR_METHOD_NOT_IMPLEMENTED ( 'lchmod()' ) ;
560
561
561
562
const fd = await open ( path , O_WRONLY | O_SYMLINK ) ;
562
- return fchmod ( fd , mode ) . finally ( fd . close ) ;
563
+ return PromisePrototypeFinally ( fchmod ( fd , mode ) , fd . close ) ;
563
564
}
564
565
565
566
async function lchown ( path , uid , gid ) {
@@ -635,7 +636,7 @@ async function writeFile(path, data, options) {
635
636
return writeFileHandle ( path , data ) ;
636
637
637
638
const fd = await open ( path , flag , options . mode ) ;
638
- return writeFileHandle ( fd , data ) . finally ( fd . close ) ;
639
+ return PromisePrototypeFinally ( writeFileHandle ( fd , data ) , fd . close ) ;
639
640
}
640
641
641
642
async function appendFile ( path , data , options ) {
@@ -653,7 +654,7 @@ async function readFile(path, options) {
653
654
return readFileHandle ( path , options ) ;
654
655
655
656
const fd = await open ( path , flag , 0o666 ) ;
656
- return readFileHandle ( fd , options ) . finally ( fd . close ) ;
657
+ return PromisePrototypeFinally ( readFileHandle ( fd , options ) , fd . close ) ;
657
658
}
658
659
659
660
module . exports = {
0 commit comments