Skip to content

Commit 7ef9c70

Browse files
baruchirodanielleadams
authored andcommitted
fs: replace finally with PromisePrototypeFinally
#35993 (comment) PR-URL: #35995 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 0a4c96a commit 7ef9c70

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/fs/promises.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
MathMin,
1616
NumberIsSafeInteger,
1717
Promise,
18+
PromisePrototypeFinally,
1819
PromiseResolve,
1920
Symbol,
2021
Uint8Array,
@@ -431,7 +432,7 @@ async function rename(oldPath, newPath) {
431432

432433
async function truncate(path, len = 0) {
433434
const fd = await open(path, 'r+');
434-
return ftruncate(fd, len).finally(fd.close);
435+
return PromisePrototypeFinally(ftruncate(fd, len), fd.close);
435436
}
436437

437438
async function ftruncate(handle, len = 0) {
@@ -559,7 +560,7 @@ async function lchmod(path, mode) {
559560
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');
560561

561562
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);
563564
}
564565

565566
async function lchown(path, uid, gid) {
@@ -635,7 +636,7 @@ async function writeFile(path, data, options) {
635636
return writeFileHandle(path, data);
636637

637638
const fd = await open(path, flag, options.mode);
638-
return writeFileHandle(fd, data).finally(fd.close);
639+
return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close);
639640
}
640641

641642
async function appendFile(path, data, options) {
@@ -653,7 +654,7 @@ async function readFile(path, options) {
653654
return readFileHandle(path, options);
654655

655656
const fd = await open(path, flag, 0o666);
656-
return readFileHandle(fd, options).finally(fd.close);
657+
return PromisePrototypeFinally(readFileHandle(fd, options), fd.close);
657658
}
658659

659660
module.exports = {

0 commit comments

Comments
 (0)