Skip to content

Commit

Permalink
fix: use fs/promises in favor of fs.promises
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed May 9, 2023
1 parent f71316d commit 98086ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/clean.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const fs = require('fs')
const fs = require('fs/promises')
const log = require('./log')

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

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

module.exports = function (gyp, argv, callback) {
Expand Down
2 changes: 1 addition & 1 deletion lib/remove.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const fs = require('fs').promises
const fs = require('fs/promises')
const path = require('path')
const log = require('./log')
const semver = require('semver')
Expand Down
18 changes: 9 additions & 9 deletions test/test-download.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const { test } = require('tap')
const fs = require('fs')
const fs = require('fs/promises')
const path = require('path')
const util = require('util')
const http = require('http')
Expand Down Expand Up @@ -44,7 +44,7 @@ test('download over https with custom ca', async (t) => {
const cacontents = certs['ca.crt']
const cert = certs['server.crt']
const key = certs['server.key']
await fs.promises.writeFile(cafile, cacontents, 'utf8')
await fs.writeFile(cafile, cacontents, 'utf8')
const ca = await install.test.readCAFile(cafile)

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

t.teardown(async () => {
await new Promise((resolve) => server.close(resolve))
await fs.promises.unlink(cafile)
await fs.unlink(cafile)
})

server.on('clientError', (err) => { throw err })
Expand Down Expand Up @@ -155,9 +155,9 @@ test('download with missing cafile', async (t) => {
test('check certificate splitting', async (t) => {
const cafile = path.join(__dirname, 'fixtures/ca-bundle.crt')
const cacontents = certs['ca-bundle.crt']
await fs.promises.writeFile(cafile, cacontents, 'utf8')
await fs.writeFile(cafile, cacontents, 'utf8')
t.teardown(async () => {
await fs.promises.unlink(cafile)
await fs.unlink(cafile)
})
const cas = await install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt'))
t.plan(2)
Expand All @@ -178,17 +178,17 @@ test('download headers (actual)', async (t) => {
t.plan(12)

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

const prog = gyp()
prog.parseArgv([])
prog.devDir = devDir
await util.promisify(install)(prog, [])

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

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

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

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

0 comments on commit 98086ab

Please sign in to comment.