Sync deps and engines with npm (#2770)

* feat!: update `engines.node` to `^14.17.0 || ^16.13.0 || >=18.0.0`

* deps: nopt@^7.0.0

* feat: replace npmlog with proc-log

* deps: standard@17.0.0 and fix linting errors

* deps: which@3.0.0
- this also promiisifies the build command

* deps: glob@8.0.3

* feat: drop rimraf dependency

* fix: use fs/promises in favor of fs.promises
This commit is contained in:
Luke Karrys 2023-06-20 06:44:18 -07:00 committed by GitHub
parent 33391db3a0
commit 192eec2aca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 536 additions and 418 deletions

View file

@ -12,7 +12,7 @@ function startsWith (str, search, pos) {
}
function processExecSync (file, args, options) {
var child, error, timeout, tmpdir, command
let error, command
command = makeCommand(file, args)
/*
@ -22,10 +22,10 @@ function processExecSync (file, args, options) {
options = options || {}
// init timeout
timeout = Date.now() + options.timeout
const timeout = Date.now() + options.timeout
// init tmpdir
var osTempBase = '/tmp'
var os = determineOS()
let osTempBase = '/tmp'
const os = determineOS()
osTempBase = '/tmp'
if (process.env.TMP) {
@ -36,7 +36,7 @@ function processExecSync (file, args, options) {
osTempBase += '/'
}
tmpdir = osTempBase + 'processExecSync.' + Date.now() + Math.random()
const tmpdir = osTempBase + 'processExecSync.' + Date.now() + Math.random()
fs.mkdirSync(tmpdir)
// init command
@ -49,13 +49,13 @@ function processExecSync (file, args, options) {
}
// init child
child = childProcess.exec(command, options)
const child = childProcess.exec(command, options)
var maxTry = 100000 // increases the test time by 6 seconds on win-2016-node-0.10
var tryCount = 0
const maxTry = 100000 // increases the test time by 6 seconds on win-2016-node-0.10
let tryCount = 0
while (tryCount < maxTry) {
try {
var x = fs.readFileSync(tmpdir + '/status')
const x = fs.readFileSync(tmpdir + '/status')
if (x.toString() === '0') {
break
}
@ -87,10 +87,10 @@ function processExecSync (file, args, options) {
}
function makeCommand (file, args) {
var command, quote
let command, quote
command = file
if (args.length > 0) {
for (var i in args) {
for (const i in args) {
command = command + ' '
if (args[i][0] === '-') {
command = command + args[i]
@ -112,8 +112,8 @@ function makeCommand (file, args) {
}
function determineOS () {
var os = ''
var tmpVar = ''
let os = ''
let tmpVar = ''
if (process.env.OSTYPE) {
tmpVar = process.env.OSTYPE
} else if (process.env.OS) {

View file

@ -6,7 +6,7 @@ const server = http.createServer(handler)
const port = +process.argv[2]
const prefix = process.argv[3]
const upstream = process.argv[4]
var calls = 0
let calls = 0
server.listen(port)
@ -15,7 +15,7 @@ function handler (req, res) {
throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']')
}
var upstreamUrl = upstream + req.url.substring(prefix.length)
const upstreamUrl = upstream + req.url.substring(prefix.length)
https.get(upstreamUrl, function (ures) {
ures.on('end', function () {
if (++calls === 2) {

View file

@ -15,24 +15,24 @@ function runHello (hostProcess) {
if (!hostProcess) {
hostProcess = process.execPath
}
var testCode = "console.log(require('hello_world').hello())"
const testCode = "console.log(require('hello_world').hello())"
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
}
function getEncoding () {
var code = 'import locale;print(locale.getdefaultlocale()[1])'
const code = 'import locale;print(locale.getdefaultlocale()[1])'
return execFileSync('python', ['-c', code]).toString().trim()
}
function checkCharmapValid () {
var data
let data
try {
data = execFileSync('python', ['fixtures/test-charmap.py'],
{ cwd: __dirname })
} catch (err) {
return false
}
var lines = data.toString().trim().split('\n')
const lines = data.toString().trim().split('\n')
return lines.pop() === 'True'
}
@ -41,10 +41,10 @@ describe('addon', function () {
it('build simple addon', function (done) {
// Set the loglevel otherwise the output disappears when run via 'npm test'
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
const cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
const proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
const logLines = stderr.toString().trim().split(/\r?\n/)
const lastLine = logLines[logLines.length - 1]
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello().trim(), 'world')
@ -59,13 +59,13 @@ describe('addon', function () {
return this.skip('python console app can\'t encode non-ascii character.')
}
var testDirNames = {
const testDirNames = {
cp936: '文件夹',
cp1252: 'Latīna',
cp932: 'フォルダ'
}
// Select non-ascii characters by current encoding
var testDirName = testDirNames[getEncoding()]
const testDirName = testDirNames[getEncoding()]
// If encoding is UTF-8 or other then no need to test
if (!testDirName) {
return this.skip('no need to test')
@ -73,17 +73,17 @@ describe('addon', function () {
this.timeout(300000)
var data
var configPath = path.join(addonPath, 'build', 'config.gypi')
let data
const configPath = path.join(addonPath, 'build', 'config.gypi')
try {
data = fs.readFileSync(configPath, 'utf8')
} catch (err) {
assert.fail(err)
return
}
var config = JSON.parse(data.replace(/#.+\n/, ''))
var nodeDir = config.variables.nodedir
var testNodeDir = path.join(addonPath, testDirName)
const config = JSON.parse(data.replace(/#.+\n/, ''))
const nodeDir = config.variables.nodedir
const testNodeDir = path.join(addonPath, testDirName)
// Create symbol link to path with non-ascii characters
try {
fs.symlinkSync(nodeDir, testNodeDir, 'dir')
@ -99,7 +99,7 @@ describe('addon', function () {
}
}
var cmd = [
const cmd = [
nodeGyp,
'rebuild',
'-C',
@ -107,15 +107,15 @@ describe('addon', function () {
'--loglevel=verbose',
'-nodedir=' + testNodeDir
]
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
const proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
try {
fs.unlink(testNodeDir)
} catch (err) {
assert.fail(err)
}
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
const logLines = stderr.toString().trim().split(/\r?\n/)
const lastLine = logLines[logLines.length - 1]
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello().trim(), 'world')
@ -133,13 +133,13 @@ describe('addon', function () {
this.timeout(300000)
var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
const notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
fs.copyFileSync(process.execPath, notNodePath)
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
var logLines = stderr.toString().trim().split(/\r?\n/)
var lastLine = logLines[logLines.length - 1]
const cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
const proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
const logLines = stderr.toString().trim().split(/\r?\n/)
const lastLine = logLines[logLines.length - 1]
assert.strictEqual(err, null)
assert.strictEqual(lastLine, 'gyp info ok', 'should end in ok')
assert.strictEqual(runHello(notNodePath).trim(), 'world')

View file

@ -5,6 +5,7 @@ const assert = require('assert')
const path = require('path')
const devDir = require('./common').devDir()
const gyp = require('../lib/node-gyp')
const log = require('../lib/log')
const requireInject = require('require-inject')
const configure = requireInject('../lib/configure', {
'graceful-fs': {
@ -21,17 +22,17 @@ const configure = requireInject('../lib/configure', {
}
})
log.logger.stream = null
const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib')
const SEPARATOR = process.platform === 'win32' ? ';' : ':'
const SPAWN_RESULT = cb => ({ on: function () { cb() } })
require('npmlog').level = 'warn'
describe('configure-python', function () {
it('configure PYTHONPATH with no existing env', function (done) {
delete process.env.PYTHONPATH
var prog = gyp()
const prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
assert.strictEqual(process.env.PYTHONPATH, EXPECTED_PYPATH)
@ -42,15 +43,15 @@ describe('configure-python', function () {
})
it('configure PYTHONPATH with existing env of one dir', function (done) {
var existingPath = path.join('a', 'b')
const existingPath = path.join('a', 'b')
process.env.PYTHONPATH = existingPath
var prog = gyp()
const prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
assert.strictEqual(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
const dirs = process.env.PYTHONPATH.split(SEPARATOR)
assert.deepStrictEqual(dirs, [EXPECTED_PYPATH, existingPath])
return SPAWN_RESULT(done)
@ -60,17 +61,17 @@ describe('configure-python', function () {
})
it('configure PYTHONPATH with existing env of multiple dirs', function (done) {
var pythonDir1 = path.join('a', 'b')
var pythonDir2 = path.join('b', 'c')
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
const pythonDir1 = path.join('a', 'b')
const pythonDir2 = path.join('b', 'c')
const existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
process.env.PYTHONPATH = existingPath
var prog = gyp()
const prog = gyp()
prog.parseArgv([])
prog.spawn = function () {
assert.strictEqual(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
const dirs = process.env.PYTHONPATH.split(SEPARATOR)
assert.deepStrictEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
return SPAWN_RESULT(done)

View file

@ -2,7 +2,7 @@
const { describe, it, after } = require('mocha')
const assert = require('assert')
const fs = require('fs')
const fs = require('fs/promises')
const path = require('path')
const util = require('util')
const http = require('http')
@ -10,12 +10,11 @@ const https = require('https')
const install = require('../lib/install')
const semver = require('semver')
const devDir = require('./common').devDir()
const rimraf = require('rimraf')
const gyp = require('../lib/node-gyp')
const log = require('npmlog')
const log = require('../lib/log')
const certs = require('./fixtures/certs')
log.level = 'warn'
log.logger.stream = null
describe('download', function () {
it('download over http', async function () {
@ -43,12 +42,12 @@ describe('download', function () {
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)
assert.strictEqual(ca.length, 1)
const options = { ca: ca, cert: cert, key: key }
const options = { ca, cert, key }
const server = https.createServer(options, (req, res) => {
assert.strictEqual(req.headers['user-agent'], `node-gyp v42 (node ${process.version})`)
res.end('ok')
@ -56,7 +55,7 @@ describe('download', function () {
after(async () => {
await new Promise((resolve) => server.close(resolve))
await fs.promises.unlink(cafile)
await fs.unlink(cafile)
})
server.on('clientError', (err) => { throw err })
@ -149,9 +148,9 @@ describe('download', function () {
it('check certificate splitting', async function () {
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')
after(async () => {
await fs.promises.unlink(cafile)
await fs.unlink(cafile)
})
const cas = await install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt'))
assert.strictEqual(cas.length, 2)
@ -171,7 +170,7 @@ describe('download', function () {
this.timeout(300000)
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
await util.promisify(rimraf)(expectedDir)
await fs.rm(expectedDir, { recursive: true, force: true })
const prog = gyp()
prog.parseArgv([])
@ -179,10 +178,10 @@ describe('download', function () {
log.level = 'warn'
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')
assert.strictEqual(data, '11\n', 'correct installVersion')
const list = await fs.promises.readdir(path.join(expectedDir, 'include/node'))
const list = await fs.readdir(path.join(expectedDir, 'include/node'))
assert.ok(list.includes('common.gypi'))
assert.ok(list.includes('config.gypi'))
assert.ok(list.includes('node.h'))
@ -194,7 +193,7 @@ describe('download', function () {
assert.ok(list.includes('v8.h'))
assert.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

View file

@ -11,7 +11,7 @@ const configure = requireInject('../lib/configure', {
if (readableFiles.some(function (f) { return f === path })) {
return 0
} else {
var error = new Error('ENOENT - not found')
const error = new Error('ENOENT - not found')
throw error
}
}
@ -30,44 +30,44 @@ const readableFiles = [
describe('find-accessible-sync', function () {
it('find accessible - empty array', function () {
var candidates = []
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = []
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, undefined)
})
it('find accessible - single item array, readable', function () {
var candidates = [readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = [readableFile]
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, path.resolve(dir, readableFile))
})
it('find accessible - single item array, readable in subdir', function () {
var candidates = [readableFileInDir]
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = [readableFileInDir]
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, path.resolve(dir, readableFileInDir))
})
it('find accessible - single item array, unreadable', function () {
var candidates = ['unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = ['unreadable_file']
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, undefined)
})
it('find accessible - multi item array, no matches', function () {
var candidates = ['non_existent_file', 'unreadable_file']
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = ['non_existent_file', 'unreadable_file']
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, undefined)
})
it('find accessible - multi item array, single match', function () {
var candidates = ['non_existent_file', readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = ['non_existent_file', readableFile]
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, path.resolve(dir, readableFile))
})
it('find accessible - multi item array, return first match', function () {
var candidates = ['non_existent_file', anotherReadableFile, readableFile]
var found = configure.test.findAccessibleSync('test', dir, candidates)
const candidates = ['non_existent_file', anotherReadableFile, readableFile]
const found = configure.test.findAccessibleSync('test', dir, candidates)
assert.strictEqual(found, path.resolve(dir, anotherReadableFile))
})
})

View file

@ -13,8 +13,8 @@ describe('find-node-directory', function () {
// in a build tree where npm is installed in
// .... /deps/npm
it('test find-node-directory - node install', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
for (let next = 0; next < platforms.length; next++) {
const processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
assert.strictEqual(
findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj),
path.join('/x'))
@ -27,8 +27,8 @@ describe('find-node-directory', function () {
// .... /lib/node_modules/npm or .../node_modules/npm
// depending on the patform
it('test find-node-directory - node build', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
for (let next = 0; next < platforms.length; next++) {
const processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
if (platforms[next] === 'win32') {
assert.strictEqual(
findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib',
@ -44,8 +44,8 @@ describe('find-node-directory', function () {
// we should find the directory based on the execPath
// for node and match because it was in the bin directory
it('test find-node-directory - node in bin directory', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
for (let next = 0; next < platforms.length; next++) {
const processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
assert.strictEqual(
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj),
path.join('/x/y'))
@ -55,8 +55,8 @@ describe('find-node-directory', function () {
// we should find the directory based on the execPath
// for node and match because it was in the Release directory
it('test find-node-directory - node in build release dir', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj
for (let next = 0; next < platforms.length; next++) {
let processObj
if (platforms[next] === 'win32') {
processObj = { execPath: '/x/y/Release/node', platform: platforms[next] }
} else {
@ -75,8 +75,8 @@ describe('find-node-directory', function () {
// we should find the directory based on the execPath
// for node and match because it was in the Debug directory
it('test find-node-directory - node in Debug release dir', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj
for (let next = 0; next < platforms.length; next++) {
let processObj
if (platforms[next] === 'win32') {
processObj = { execPath: '/a/b/Debug/node', platform: platforms[next] }
} else {
@ -92,8 +92,8 @@ describe('find-node-directory', function () {
// we should not find it as it will not match based on the execPath nor
// the directory from which the script is running
it('test find-node-directory - not found', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/z/y', platform: next }
for (let next = 0; next < platforms.length; next++) {
const processObj = { execPath: '/x/y/z/y', platform: next }
assert.strictEqual(findNodeDirectory('/a/b/c/d', processObj), '')
}
})
@ -105,8 +105,8 @@ describe('find-node-directory', function () {
// same test as above but make sure additional directory entries
// don't cause an issue
it('test find-node-directory - node install', function () {
for (var next = 0; next < platforms.length; next++) {
var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
for (let next = 0; next < platforms.length; next++) {
const processObj = { execPath: '/x/y/bin/node', platform: platforms[next] }
assert.strictEqual(
findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib',
processObj), path.join('/x/y/z/a/b/c'))

View file

@ -8,13 +8,11 @@ const findPython = require('../lib/find-python')
const execFile = require('child_process').execFile
const PythonFinder = findPython.test.PythonFinder
require('npmlog').level = 'warn'
describe('find-python', function () {
it('find python', function () {
findPython.test.findPython(null, function (err, found) {
assert.strictEqual(err, null)
var proc = execFile(found, ['-V'], function (err, stdout, stderr) {
const proc = execFile(found, ['-V'], function (err, stdout, stderr) {
assert.strictEqual(err, null)
assert.ok(/Python 3/.test(stdout))
assert.strictEqual(stderr, '')
@ -29,7 +27,7 @@ describe('find-python', function () {
console.error(Error(`Property ${property} should not have been accessed.`))
process.abort()
}
var descriptor = {
const descriptor = {
configurable: false,
enumerable: false,
get: fail,
@ -42,18 +40,10 @@ describe('find-python', function () {
PythonFinder.apply(this, arguments)
}
TestPythonFinder.prototype = Object.create(PythonFinder.prototype)
// Silence npmlog - remove for debugging
TestPythonFinder.prototype.log = {
silly: () => {},
verbose: () => {},
info: () => {},
warn: () => {},
error: () => {}
}
delete TestPythonFinder.prototype.env.NODE_GYP_FORCE_PYTHON
it('find python - python', function () {
var f = new TestPythonFinder('python', done)
const f = new TestPythonFinder('python', done)
f.execFile = function (program, args, opts, cb) {
f.execFile = function (program, args, opts, cb) {
poison(f, 'execFile')
@ -75,7 +65,7 @@ describe('find-python', function () {
})
it('find python - python too old', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(null, '/path/python')
@ -94,7 +84,7 @@ describe('find-python', function () {
})
it('find python - no python', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.execFile = function (program, args, opts, cb) {
if (/sys\.executable/.test(args[args.length - 1])) {
cb(new Error('not found'))
@ -113,7 +103,7 @@ describe('find-python', function () {
})
it('find python - no python2, no python, unix', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.checkPyLauncher = assert.fail
f.win = false
@ -133,7 +123,7 @@ describe('find-python', function () {
})
it('find python - no python, use python launcher', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function (program, args, opts, cb) {
@ -165,7 +155,7 @@ describe('find-python', function () {
})
it('find python - no python, no python launcher, good guess', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.win = true
const expectedProgram = f.winDefaultLocations[0]
@ -191,7 +181,7 @@ describe('find-python', function () {
})
it('find python - no python, no python launcher, bad guess', function () {
var f = new TestPythonFinder(null, done)
const f = new TestPythonFinder(null, done)
f.win = true
f.execFile = function (program, args, opts, cb) {

View file

@ -16,7 +16,7 @@ function poison (object, property) {
console.error(Error(`Property ${property} should not have been accessed.`))
process.abort()
}
var descriptor = {
const descriptor = {
configurable: false,
enumerable: false,
get: fail,
@ -27,14 +27,6 @@ function poison (object, property) {
function TestVisualStudioFinder () { VisualStudioFinder.apply(this, arguments) }
TestVisualStudioFinder.prototype = Object.create(VisualStudioFinder.prototype)
// Silence npmlog - remove for debugging
TestVisualStudioFinder.prototype.log = {
silly: () => {},
verbose: () => {},
info: () => {},
warn: () => {},
error: () => {}
}
describe('find-visualstudio', function () {
it('VS2013', function () {
@ -56,7 +48,7 @@ describe('find-visualstudio', function () {
finder.parseData(new Error(), '', '', cb)
}
finder.regSearchKeys = (keys, value, addOpts, cb) => {
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const fullName = `${keys[i]}\\${value}`
switch (fullName) {
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
@ -93,7 +85,7 @@ describe('find-visualstudio', function () {
finder.parseData(null, data, '', cb)
}
finder.regSearchKeys = (keys, value, addOpts, cb) => {
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const fullName = `${keys[i]}\\${value}`
switch (fullName) {
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
@ -127,7 +119,7 @@ describe('find-visualstudio', function () {
finder.parseData(new Error(), '', '', cb)
}
finder.regSearchKeys = (keys, value, addOpts, cb) => {
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const fullName = `${keys[i]}\\${value}`
switch (fullName) {
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':
@ -439,7 +431,7 @@ describe('find-visualstudio', function () {
finder.parseData(null, data, '', cb)
}
finder.regSearchKeys = (keys, value, addOpts, cb) => {
for (var i = 0; i < keys.length; ++i) {
for (let i = 0; i < keys.length; ++i) {
const fullName = `${keys[i]}\\${value}`
switch (fullName) {
case 'HKLM\\Software\\Microsoft\\VisualStudio\\SxS\\VC7\\14.0':

View file

@ -1,20 +1,17 @@
'use strict'
const { describe, it, after } = require('mocha')
const { rm } = require('fs/promises')
const assert = require('assert')
const path = require('path')
const os = require('os')
const util = require('util')
const { test: { download, install } } = require('../lib/install')
const rimraf = require('rimraf')
const gyp = require('../lib/node-gyp')
const log = require('npmlog')
const semver = require('semver')
const stream = require('stream')
const streamPipeline = util.promisify(stream.pipeline)
log.level = 'error' // we expect a warning
describe('install', function () {
it('EACCES retry once', async () => {
const fs = {
@ -65,11 +62,11 @@ describe('install', function () {
}
after(async () => {
await util.promisify(rimraf)(devDir)
await rm(devDir, { recursive: true, force: true })
})
const expectedDir = path.join(devDir, process.version.replace(/^v/, ''))
await util.promisify(rimraf)(expectedDir)
await rm(expectedDir, { recursive: true, force: true })
await Promise.all([
install(fs, prog, []),
@ -95,7 +92,6 @@ describe('install', function () {
prog.parseArgv([])
prog.devDir = devDir
prog.opts.ensure = true
log.level = 'warn'
await parallelInstallsTest(this, fs, devDir, prog)
})
@ -110,7 +106,6 @@ describe('install', function () {
prog.parseArgv([])
prog.devDir = devDir
prog.opts.ensure = false
log.level = 'warn'
await parallelInstallsTest(this, fs, devDir, prog)
})
@ -125,7 +120,6 @@ describe('install', function () {
prog.parseArgv([])
prog.devDir = devDir
prog.opts.tarball = path.join(devDir, 'node-headers.tar.gz')
log.level = 'warn'
await streamPipeline(
(await download(prog, `https://nodejs.org/dist/${process.version}/node-${process.version}.tar.gz`)).body,

View file

@ -6,7 +6,7 @@ const processRelease = require('../lib/process-release')
describe('process-release', function () {
it('test process release - process.version = 0.8.20', function () {
var release = processRelease([], { opts: {} }, 'v0.8.20', null)
const release = processRelease([], { opts: {} }, 'v0.8.20', null)
assert.strictEqual(release.semver.version, '0.8.20')
delete release.semver
@ -25,7 +25,7 @@ describe('process-release', function () {
})
it('test process release - process.version = 0.10.21', function () {
var release = processRelease([], { opts: {} }, 'v0.10.21', null)
const release = processRelease([], { opts: {} }, 'v0.10.21', null)
assert.strictEqual(release.semver.version, '0.10.21')
delete release.semver
@ -45,7 +45,7 @@ describe('process-release', function () {
// prior to -headers.tar.gz
it('test process release - process.version = 0.12.9', function () {
var release = processRelease([], { opts: {} }, 'v0.12.9', null)
const release = processRelease([], { opts: {} }, 'v0.12.9', null)
assert.strictEqual(release.semver.version, '0.12.9')
delete release.semver
@ -65,7 +65,7 @@ describe('process-release', function () {
// prior to -headers.tar.gz
it('test process release - process.version = 0.10.41', function () {
var release = processRelease([], { opts: {} }, 'v0.10.41', null)
const release = processRelease([], { opts: {} }, 'v0.10.41', null)
assert.strictEqual(release.semver.version, '0.10.41')
delete release.semver
@ -85,7 +85,7 @@ describe('process-release', function () {
// has -headers.tar.gz
it('test process release - process.release ~ node@0.10.42', function () {
var release = processRelease([], { opts: {} }, 'v0.10.42', null)
const release = processRelease([], { opts: {} }, 'v0.10.42', null)
assert.strictEqual(release.semver.version, '0.10.42')
delete release.semver
@ -105,7 +105,7 @@ describe('process-release', function () {
// has -headers.tar.gz
it('test process release - process.release ~ node@0.12.10', function () {
var release = processRelease([], { opts: {} }, 'v0.12.10', null)
const release = processRelease([], { opts: {} }, 'v0.12.10', null)
assert.strictEqual(release.semver.version, '0.12.10')
delete release.semver
@ -124,7 +124,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@4.1.23', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
const release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
@ -146,7 +146,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@4.1.23 / corp build', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
const release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://some.custom.location/node-v4.1.23-headers.tar.gz'
})
@ -168,7 +168,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@12.8.0 Windows', function () {
var release = processRelease([], { opts: {} }, 'v12.8.0', {
const release = processRelease([], { opts: {} }, 'v12.8.0', {
name: 'node',
sourceUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz',
headersUrl: 'https://nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
@ -192,7 +192,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@12.8.0 Windows ARM64', function () {
var release = processRelease([], { opts: {} }, 'v12.8.0', {
const release = processRelease([], { opts: {} }, 'v12.8.0', {
name: 'node',
sourceUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0.tar.gz',
headersUrl: 'https://unofficial-builds.nodejs.org/download/release/v12.8.0/node-v12.8.0-headers.tar.gz',
@ -216,7 +216,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@4.1.23 --target=0.10.40', function () {
var release = processRelease([], { opts: { target: '0.10.40' } }, 'v4.1.23', {
const release = processRelease([], { opts: { target: '0.10.40' } }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
@ -238,7 +238,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@4.1.23 --dist-url=https://foo.bar/baz', function () {
var release = processRelease([], { opts: { 'dist-url': 'https://foo.bar/baz' } }, 'v4.1.23', {
const release = processRelease([], { opts: { 'dist-url': 'https://foo.bar/baz' } }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})
@ -260,7 +260,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ frankenstein@4.1.23', function () {
var release = processRelease([], { opts: {} }, 'v4.1.23', {
const release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'frankenstein',
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23-headers.tar.gz'
})
@ -282,7 +282,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function () {
var release = processRelease([], { opts: { 'dist-url': 'http://foo.bar/baz/' } }, 'v4.1.23', {
const release = processRelease([], { opts: { 'dist-url': 'http://foo.bar/baz/' } }, 'v4.1.23', {
name: 'frankenstein',
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23.tar.gz'
})
@ -304,7 +304,7 @@ describe('process-release', function () {
})
it('test process release - process.release ~ node@4.0.0-rc.4', function () {
var release = processRelease([], { opts: {} }, 'v4.0.0-rc.4', {
const release = processRelease([], { opts: {} }, 'v4.0.0-rc.4', {
name: 'node',
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
@ -328,7 +328,7 @@ describe('process-release', function () {
it('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function () {
// note the missing 'v' on the arg, it should normalise when checking
// whether we're on the default or not
var release = processRelease(['4.0.0-rc.4'], { opts: {} }, 'v4.0.0-rc.4', {
const release = processRelease(['4.0.0-rc.4'], { opts: {} }, 'v4.0.0-rc.4', {
name: 'node',
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
@ -352,7 +352,7 @@ describe('process-release', function () {
it('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function () {
// additional arguments can be passed in on the commandline that should be ignored if they
// are not specifying a valid version @ position 0
var release = processRelease(['this is no version!'], { opts: {} }, 'v4.0.0-rc.4', {
const release = processRelease(['this is no version!'], { opts: {} }, 'v4.0.0-rc.4', {
name: 'node',
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz'
})
@ -376,7 +376,7 @@ describe('process-release', function () {
it('test process release - NODEJS_ORG_MIRROR', function () {
process.env.NODEJS_ORG_MIRROR = 'http://foo.bar'
var release = processRelease([], { opts: {} }, 'v4.1.23', {
const release = processRelease([], { opts: {} }, 'v4.1.23', {
name: 'node',
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
})