mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
fs: replace finally with PromisePrototypeFinally
https://github.com/nodejs/node/pull/35993#discussion_r518703665 PR-URL: https://github.com/nodejs/node/pull/35995 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
0477e000bf
commit
7c3b6f17e3
1 file changed
+5
-4
@@ -15,6 +15,7 @@ const {
|
||||
MathMin,
|
||||
NumberIsSafeInteger,
|
||||
Promise,
|
||||
PromisePrototypeFinally,
|
||||
PromiseResolve,
|
||||
Symbol,
|
||||
Uint8Array,
|
||||
@@ -410,7 +411,7 @@ async function rename(oldPath, newPath) {
|
||||
|
||||
async function truncate(path, len = 0) {
|
||||
const fd = await open(path, 'r+');
|
||||
return ftruncate(fd, len).finally(fd.close);
|
||||
return PromisePrototypeFinally(ftruncate(fd, len), fd.close);
|
||||
}
|
||||
|
||||
async function ftruncate(handle, len = 0) {
|
||||
@@ -538,7 +539,7 @@ async function lchmod(path, mode) {
|
||||
throw new ERR_METHOD_NOT_IMPLEMENTED('lchmod()');
|
||||
|
||||
const fd = await open(path, O_WRONLY | O_SYMLINK);
|
||||
return fchmod(fd, mode).finally(fd.close);
|
||||
return PromisePrototypeFinally(fchmod(fd, mode), fd.close);
|
||||
}
|
||||
|
||||
async function lchown(path, uid, gid) {
|
||||
@@ -614,7 +615,7 @@ async function writeFile(path, data, options) {
|
||||
return writeFileHandle(path, data);
|
||||
|
||||
const fd = await open(path, flag, options.mode);
|
||||
return writeFileHandle(fd, data).finally(fd.close);
|
||||
return PromisePrototypeFinally(writeFileHandle(fd, data), fd.close);
|
||||
}
|
||||
|
||||
async function appendFile(path, data, options) {
|
||||
@@ -632,7 +633,7 @@ async function readFile(path, options) {
|
||||
return readFileHandle(path, options);
|
||||
|
||||
const fd = await open(path, flag, 0o666);
|
||||
return readFileHandle(fd, options).finally(fd.close);
|
||||
return PromisePrototypeFinally(readFileHandle(fd, options), fd.close);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in new issue
Block a user