From a948dc0908fd605539cca60aec64c28e67d1c38a Mon Sep 17 00:00:00 2001 From: SukkaW Date: Fri, 20 Oct 2023 10:43:30 +0800 Subject: [PATCH] Use promisfied fs API from `lib/fs` --- lib/util/utimes.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/util/utimes.js b/lib/util/utimes.js index 2cea485d..a6b5c7bf 100644 --- a/lib/util/utimes.js +++ b/lib/util/utimes.js @@ -1,11 +1,6 @@ 'use strict' -const fs = require('graceful-fs') -const { promisify } = require('util') - -const open = promisify(fs.open) -const futimes = promisify(fs.futimes) -const close = promisify(fs.close) +const fs = require('../fs') // TODO: remove `utimesMillis` once all internal usage has switched to the Promise-based `utimesMillisAsync` API function utimesMillis (path, atime, mtime, callback) { @@ -22,11 +17,11 @@ function utimesMillis (path, atime, mtime, callback) { async function utimesMillisAsync (path, atime, mtime) { // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback) - const fd = await open(path, 'r+') + const fd = await fs.open(path, 'r+') let futimesErr = null try { - await futimes(fd, atime, mtime) + await fs.futimes(fd, atime, mtime) } catch (e) { futimesErr = e } @@ -34,7 +29,7 @@ async function utimesMillisAsync (path, atime, mtime) { let closeErr = null try { - await close(fd) + await fs.close(fd) } catch (e) { closeErr = e }