Skip to content

Commit 7c3b6f1

Browse files
baruchiroBethGriggs
authored andcommittedDec 15, 2020
fs: replace finally with PromisePrototypeFinally
#35993 (comment) PR-URL: #35995 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0477e00 commit 7c3b6f1

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,
@@ -410,7 +411,7 @@ async function rename(oldPath, newPath) {
410411

411412
async function truncate(path, len = 0) {
412413
const fd = await open(path, 'r+');
413-
return ftruncate(fd, len).finally(fd.close);
414+
return PromisePrototypeFinally(ftruncate(fd, len), fd.close);
414415
}
415416

416417
async function ftruncate(handle, len = 0) {
@@ -538,7 +539,7 @@ async function lchmod(path, mode) {
538539
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');
539540

540541
const fd = await open(path, O_WRONLY | O_SYMLINK);
541-
return fchmod(fd, mode).finally(fd.close);
542+
return PromisePrototypeFinally(fchmod(fd, mode), fd.close);
542543
}
543544

544545
async function lchown(path, uid, gid) {
@@ -614,7 +615,7 @@ async function writeFile(path, data, options) {
614615
return writeFileHandle(path, data);
615616

616617
const fd = await open(path, flag, options.mode);
617-
return writeFileHandle(fd, data).finally(fd.close);
618+
return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close);
618619
}
619620

620621
async function appendFile(path, data, options) {
@@ -632,7 +633,7 @@ async function readFile(path, options) {
632633
return readFileHandle(path, options);
633634

634635
const fd = await open(path, flag, 0o666);
635-
return readFileHandle(fd, options).finally(fd.close);
636+
return PromisePrototypeFinally(readFileHandle(fd, options), fd.close);
636637
}
637638

638639
module.exports = {

0 commit comments

Comments
 (0)
Please sign in to comment.