Skip to content

Commit 8c4a100

Browse files
committed
fix: use fs/promises in favor of fs.promises
1 parent aeac6a7 commit 8c4a100

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lib/clean.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict'
22

3-
const fs = require('fs')
3+
const fs = require('fs/promises')
44
const log = require('./log')
55

66
async function clean (gyp, argv) {
77
// Remove the 'build' dir
88
const buildDir = 'build'
99

1010
log.verbose('clean', 'removing "%s" directory', buildDir)
11-
await fs.promises.rm(buildDir, { recursive: true, force: true })
11+
await fs.rm(buildDir, { recursive: true, force: true })
1212
}
1313

1414
module.exports = function (gyp, argv, callback) {

lib/remove.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const fs = require('fs').promises
3+
const fs = require('fs/promises')
44
const path = require('path')
55
const log = require('./log')
66
const semver = require('semver')

test/test-download.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const { test } = require('tap')
4-
const fs = require('fs')
4+
const fs = require('fs/promises')
55
const path = require('path')
66
const util = require('util')
77
const http = require('http')
@@ -44,7 +44,7 @@ test('download over https with custom ca', async (t) => {
4444
const cacontents = certs['ca.crt']
4545
const cert = certs['server.crt']
4646
const key = certs['server.key']
47-
await fs.promises.writeFile(cafile, cacontents, 'utf8')
47+
await fs.writeFile(cafile, cacontents, 'utf8')
4848
const ca = await install.test.readCAFile(cafile)
4949

5050
t.equal(ca.length, 1)
@@ -57,7 +57,7 @@ test('download over https with custom ca', async (t) => {
5757

5858
t.teardown(async () => {
5959
await new Promise((resolve) => server.close(resolve))
60-
await fs.promises.unlink(cafile)
60+
await fs.unlink(cafile)
6161
})
6262

6363
server.on('clientError', (err) => { throw err })
@@ -155,9 +155,9 @@ test('download with missing cafile', async (t) => {
155155
test('check certificate splitting', async (t) => {
156156
const cafile = path.join(__dirname, 'fixtures/ca-bundle.crt')
157157
const cacontents = certs['ca-bundle.crt']
158-
await fs.promises.writeFile(cafile, cacontents, 'utf8')
158+
await fs.writeFile(cafile, cacontents, 'utf8')
159159
t.teardown(async () => {
160-
await fs.promises.unlink(cafile)
160+
await fs.unlink(cafile)
161161
})
162162
const cas = await install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt'))
163163
t.plan(2)
@@ -178,17 +178,17 @@ test('download headers (actual)', async (t) => {
178178
t.plan(12)
179179

180180
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
181-
await fs.promises.rm(expectedDir, { recursive: true, force: true })
181+
await fs.rm(expectedDir, { recursive: true, force: true })
182182

183183
const prog = gyp()
184184
prog.parseArgv([])
185185
prog.devDir = devDir
186186
await util.promisify(install)(prog, [])
187187

188-
const data = await fs.promises.readFile(path.join(expectedDir, 'installVersion'), 'utf8')
188+
const data = await fs.readFile(path.join(expectedDir, 'installVersion'), 'utf8')
189189
t.equal(data, '9\n', 'correct installVersion')
190190

191-
const list = await fs.promises.readdir(path.join(expectedDir, 'include/node'))
191+
const list = await fs.readdir(path.join(expectedDir, 'include/node'))
192192
t.ok(list.includes('common.gypi'))
193193
t.ok(list.includes('config.gypi'))
194194
t.ok(list.includes('node.h'))
@@ -200,7 +200,7 @@ test('download headers (actual)', async (t) => {
200200
t.ok(list.includes('v8.h'))
201201
t.ok(list.includes('zlib.h'))
202202

203-
const lines = (await fs.promises.readFile(path.join(expectedDir, 'include/node/node_version.h'), 'utf8')).split('\n')
203+
const lines = (await fs.readFile(path.join(expectedDir, 'include/node/node_version.h'), 'utf8')).split('\n')
204204

205205
// extract the 3 version parts from the defines to build a valid version string and
206206
// and check them against our current env version

0 commit comments

Comments
 (0)