Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: replace finally with PromisePrototypeFinally #35995

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/internal/fs/promises.js
Expand Up @@ -15,6 +15,7 @@ const {
MathMin,
NumberIsSafeInteger,
Promise,
PromisePrototypeFinally,
PromiseResolve,
Symbol,
Uint8Array,
Expand Down Expand Up @@ -431,7 +432,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) {
Expand Down Expand Up @@ -559,7 +560,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) {
Expand Down Expand Up @@ -635,7 +636,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);
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}

async function appendFile(path, data, options) {
Expand All @@ -653,7 +654,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 = {
Expand Down