Skip to content

Commit d9f8ef9

Browse files
committed
Use promisfied fs API from lib/fs
1 parent e125aa2 commit d9f8ef9

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/util/__tests__/utimes.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('utimes', () => {
3333
fse.emptyDir(TEST_DIR, done)
3434
// reset stubs
3535
gracefulFsStub = {}
36-
utimes = proxyquire('../utimes', { 'graceful-fs': gracefulFsStub })
36+
utimes = proxyquire('../utimes', { '../fs': gracefulFsStub })
3737
})
3838

3939
describe('utimesMillis()', () => {

lib/util/utimes.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
'use strict'
22

3-
const fs = require('graceful-fs')
4-
const { promisify } = require('util')
5-
6-
const open = promisify(fs.open)
7-
const futimes = promisify(fs.futimes)
8-
const close = promisify(fs.close)
3+
const fs = require('../fs')
94

105
// TODO: remove `utimesMillis` once all internal usage has switched to the Promise-based `utimesMillisAsync` API
116
function utimesMillis (path, atime, mtime, callback) {
@@ -22,19 +17,19 @@ function utimesMillis (path, atime, mtime, callback) {
2217

2318
async function utimesMillisAsync (path, atime, mtime) {
2419
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
25-
const fd = await open(path, 'r+')
20+
const fd = await fs.open(path, 'r+')
2621

2722
let futimesErr = null
2823
try {
29-
await futimes(fd, atime, mtime)
24+
await fs.futimes(fd, atime, mtime)
3025
} catch (e) {
3126
futimesErr = e
3227
}
3328

3429
let closeErr = null
3530

3631
try {
37-
await close(fd)
32+
await fs.close(fd)
3833
} catch (e) {
3934
closeErr = e
4035
}

0 commit comments

Comments
 (0)