diff options
Diffstat (limited to 'node_modules/fs-extra/lib/util/utimes.js')
| -rw-r--r-- | node_modules/fs-extra/lib/util/utimes.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/node_modules/fs-extra/lib/util/utimes.js b/node_modules/fs-extra/lib/util/utimes.js index 75395def..87f4588c 100644 --- a/node_modules/fs-extra/lib/util/utimes.js +++ b/node_modules/fs-extra/lib/util/utimes.js @@ -1,17 +1,27 @@ 'use strict' -const fs = require('graceful-fs') +const fs = require('../fs') +const u = require('universalify').fromPromise -function utimesMillis (path, atime, mtime, callback) { +async function utimesMillis (path, atime, mtime) { // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback) - fs.open(path, 'r+', (err, fd) => { - if (err) return callback(err) - fs.futimes(fd, atime, mtime, futimesErr => { - fs.close(fd, closeErr => { - if (callback) callback(futimesErr || closeErr) - }) - }) - }) + const fd = await fs.open(path, 'r+') + + let closeErr = null + + try { + await fs.futimes(fd, atime, mtime) + } finally { + try { + await fs.close(fd) + } catch (e) { + closeErr = e + } + } + + if (closeErr) { + throw closeErr + } } function utimesMillisSync (path, atime, mtime) { @@ -21,6 +31,6 @@ function utimesMillisSync (path, atime, mtime) { } module.exports = { - utimesMillis, + utimesMillis: u(utimesMillis), utimesMillisSync } |
