Skip to content

Commit 734ae27

Browse files
committedNov 12, 2021
Bump standard devDependency
1 parent 477f347 commit 734ae27

16 files changed

+266
-265
lines changed
 

‎asset.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
var get = require('simple-get')
2-
var util = require('./util')
3-
var proxy = require('./proxy')
1+
const get = require('simple-get')
2+
const util = require('./util')
3+
const proxy = require('./proxy')
44

55
function findAssetId (opts, cb) {
6-
var downloadUrl = util.getDownloadUrl(opts)
7-
var apiUrl = util.getApiUrl(opts)
8-
var log = opts.log || util.noopLogger
6+
const downloadUrl = util.getDownloadUrl(opts)
7+
const apiUrl = util.getApiUrl(opts)
8+
const log = opts.log || util.noopLogger
99

1010
log.http('request', 'GET ' + apiUrl)
11-
var reqOpts = proxy({
11+
const reqOpts = proxy({
1212
url: apiUrl,
1313
json: true,
1414
headers: {
@@ -17,15 +17,15 @@ function findAssetId (opts, cb) {
1717
}
1818
}, opts)
1919

20-
var req = get.concat(reqOpts, function (err, res, data) {
20+
const req = get.concat(reqOpts, function (err, res, data) {
2121
if (err) return cb(err)
2222
log.http(res.statusCode, apiUrl)
2323
if (res.statusCode !== 200) return cb(err)
2424

2525
// Find asset id in release
26-
for (var release of data) {
26+
for (const release of data) {
2727
if (release.tag_name === opts['tag-prefix'] + opts.pkg.version) {
28-
for (var asset of release.assets) {
28+
for (const asset of release.assets) {
2929
if (asset.browser_download_url === downloadUrl) {
3030
return cb(null, asset.id)
3131
}

‎bin.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/usr/bin/env node
22

3-
var path = require('path')
4-
var fs = require('fs')
5-
var napi = require('napi-build-utils')
3+
const path = require('path')
4+
const fs = require('fs')
5+
const napi = require('napi-build-utils')
66

7-
var pkg = require(path.resolve('package.json'))
8-
var rc = require('./rc')(pkg)
9-
var log = require('./log')(rc, process.env)
10-
var download = require('./download')
11-
var asset = require('./asset')
12-
var util = require('./util')
7+
const pkg = require(path.resolve('package.json'))
8+
const rc = require('./rc')(pkg)
9+
const log = require('./log')(rc, process.env)
10+
const download = require('./download')
11+
const asset = require('./asset')
12+
const util = require('./util')
1313

14-
var prebuildClientVersion = require('./package.json').version
14+
const prebuildClientVersion = require('./package.json').version
1515
if (rc.version) {
1616
console.log(prebuildClientVersion)
1717
process.exit(0)
@@ -37,11 +37,11 @@ if (rc.help) {
3737

3838
log.info('begin', 'Prebuild-install version', prebuildClientVersion)
3939

40-
var opts = Object.assign({}, rc, { pkg: pkg, log: log })
40+
const opts = Object.assign({}, rc, { pkg: pkg, log: log })
4141

4242
if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log)
4343

44-
var origin = util.packageOrigin(process.env, pkg)
44+
const origin = util.packageOrigin(process.env, pkg)
4545

4646
if (opts.force) {
4747
log.warn('install', 'prebuilt binaries enforced with --force!')
@@ -54,7 +54,7 @@ if (opts.force) {
5454
process.exit(1)
5555
}
5656

57-
var startDownload = function (downloadUrl) {
57+
const startDownload = function (downloadUrl) {
5858
download(downloadUrl, opts, function (err) {
5959
if (err) {
6060
log.warn('install', err.message)

‎download.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
var path = require('path')
2-
var fs = require('fs')
3-
var get = require('simple-get')
4-
var pump = require('pump')
5-
var tfs = require('tar-fs')
6-
var zlib = require('zlib')
7-
var util = require('./util')
8-
var error = require('./error')
9-
var proxy = require('./proxy')
10-
var mkdirp = require('mkdirp-classic')
1+
const path = require('path')
2+
const fs = require('fs')
3+
const get = require('simple-get')
4+
const pump = require('pump')
5+
const tfs = require('tar-fs')
6+
const zlib = require('zlib')
7+
const util = require('./util')
8+
const error = require('./error')
9+
const proxy = require('./proxy')
10+
const mkdirp = require('mkdirp-classic')
1111

1212
function downloadPrebuild (downloadUrl, opts, cb) {
13-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
14-
var localPrebuild = util.localPrebuild(downloadUrl, opts)
15-
var tempFile = util.tempFile(cachedPrebuild)
16-
var log = opts.log || util.noopLogger
13+
let cachedPrebuild = util.cachedPrebuild(downloadUrl)
14+
const localPrebuild = util.localPrebuild(downloadUrl, opts)
15+
const tempFile = util.tempFile(cachedPrebuild)
16+
const log = opts.log || util.noopLogger
1717

1818
if (opts.nolocal) return download()
1919

@@ -40,7 +40,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
4040
}
4141

4242
log.http('request', 'GET ' + downloadUrl)
43-
var reqOpts = proxy({ url: downloadUrl }, opts)
43+
const reqOpts = proxy({ url: downloadUrl }, opts)
4444

4545
if (opts.token) {
4646
reqOpts.headers = {
@@ -50,7 +50,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
5050
}
5151
}
5252

53-
var req = get(reqOpts, function (err, res) {
53+
const req = get(reqOpts, function (err, res) {
5454
if (err) return onerror(err)
5555
log.http(res.statusCode, downloadUrl)
5656
if (res.statusCode !== 200) return onerror()
@@ -81,26 +81,26 @@ function downloadPrebuild (downloadUrl, opts, cb) {
8181
}
8282

8383
function unpack () {
84-
var binaryName
84+
let binaryName
8585

86-
var updateName = opts.updateName || function (entry) {
86+
const updateName = opts.updateName || function (entry) {
8787
if (/\.node$/i.test(entry.name)) binaryName = entry.name
8888
}
8989

9090
log.info('unpacking @', cachedPrebuild)
9191

92-
var options = {
92+
const options = {
9393
readable: true,
9494
writable: true,
9595
hardlinkAsFilesFallback: true
9696
}
97-
var extract = tfs.extract(opts.path, options).on('entry', updateName)
97+
const extract = tfs.extract(opts.path, options).on('entry', updateName)
9898

9999
pump(fs.createReadStream(cachedPrebuild), zlib.createGunzip(), extract,
100100
function (err) {
101101
if (err) return cb(err)
102102

103-
var resolved
103+
let resolved
104104
if (binaryName) {
105105
try {
106106
resolved = path.resolve(opts.path || '.', binaryName)
@@ -124,7 +124,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
124124
}
125125

126126
function ensureNpmCacheDir (cb) {
127-
var cacheFolder = util.npmCache()
127+
const cacheFolder = util.npmCache()
128128
fs.access(cacheFolder, fs.R_OK | fs.W_OK, function (err) {
129129
if (err && err.code === 'ENOENT') {
130130
return makeNpmCacheDir()

‎log.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var log = require('npmlog')
2-
var fs = require('fs')
3-
var path = require('path')
1+
const log = require('npmlog')
2+
const fs = require('fs')
3+
const path = require('path')
44

55
module.exports = function (rc, env) {
66
log.heading = 'prebuild-install'
@@ -13,7 +13,7 @@ module.exports = function (rc, env) {
1313

1414
// Temporary workaround for npm 7 which swallows our output
1515
if (process.env.npm_config_prebuild_install_logfile) {
16-
var fp = path.resolve(process.env.npm_config_prebuild_install_logfile)
16+
const fp = path.resolve(process.env.npm_config_prebuild_install_logfile)
1717

1818
log.on('log', function (msg) {
1919
// Only for tests, don't care about performance

‎package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"version": "6.1.4",
44
"description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
55
"scripts": {
6-
"test": "tape test/*-test.js && npm run lint",
7-
"lint": "standard && hallmark",
6+
"test": "standard && hallmark && tape test/*-test.js",
87
"hallmark": "hallmark --fix"
98
},
109
"keywords": [
@@ -39,7 +38,7 @@
3938
"hallmark": "^3.0.0",
4039
"nock": "^10.0.6",
4140
"rimraf": "^2.5.2",
42-
"standard": "^13.0.2",
41+
"standard": "^16.0.4",
4342
"tape": "^4.5.1",
4443
"tempy": "0.2.1"
4544
},

‎proxy.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
var url = require('url')
2-
var tunnel = require('tunnel-agent')
3-
var util = require('./util')
1+
const url = require('url')
2+
const tunnel = require('tunnel-agent')
3+
const util = require('./util')
44

55
function applyProxy (reqOpts, opts) {
6-
var log = opts.log || util.noopLogger
6+
const log = opts.log || util.noopLogger
77

8-
var proxy = opts['https-proxy'] || opts.proxy
8+
const proxy = opts['https-proxy'] || opts.proxy
99

1010
if (proxy) {
1111
// eslint-disable-next-line node/no-deprecated-api
12-
var parsedDownloadUrl = url.parse(reqOpts.url)
12+
const parsedDownloadUrl = url.parse(reqOpts.url)
1313
// eslint-disable-next-line node/no-deprecated-api
14-
var parsedProxy = url.parse(proxy)
15-
var uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
16-
var proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
17-
var tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
14+
const parsedProxy = url.parse(proxy)
15+
const uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
16+
const proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
17+
const tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
1818
reqOpts.agent = tunnel[tunnelFnName]({
1919
proxy: {
2020
host: parsedProxy.hostname,

‎rc.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
var path = require('path')
2-
var minimist = require('minimist')
3-
var getAbi = require('node-abi').getAbi
4-
var detectLibc = require('detect-libc')
5-
var napi = require('napi-build-utils')
1+
const path = require('path')
2+
const minimist = require('minimist')
3+
const getAbi = require('node-abi').getAbi
4+
const detectLibc = require('detect-libc')
5+
const napi = require('napi-build-utils')
66

7-
var env = process.env
8-
var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
7+
const env = process.env
8+
const libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
99

1010
// Get the configuration
1111
module.exports = function (pkg) {
12-
var pkgConf = pkg.config || {}
13-
var buildFromSource = env.npm_config_build_from_source
12+
const pkgConf = pkg.config || {}
13+
const buildFromSource = env.npm_config_build_from_source
1414

15-
var rc = require('rc')('prebuild-install', {
15+
const rc = require('rc')('prebuild-install', {
1616
target: pkgConf.target || env.npm_config_target || process.versions.node,
1717
runtime: pkgConf.runtime || env.npm_config_runtime || 'node',
1818
arch: pkgConf.arch || env.npm_config_arch || process.arch,
@@ -23,8 +23,8 @@ module.exports = function (pkg) {
2323
verbose: env.npm_config_verbose === 'true',
2424
buildFromSource: buildFromSource === pkg.name || buildFromSource === 'true',
2525
path: '.',
26-
proxy: env.npm_config_proxy || env['http_proxy'] || env['HTTP_PROXY'],
27-
'https-proxy': env.npm_config_https_proxy || env['https_proxy'] || env['HTTPS_PROXY'],
26+
proxy: env.npm_config_proxy || env.http_proxy || env.HTTP_PROXY,
27+
'https-proxy': env.npm_config_https_proxy || env.https_proxy || env.HTTPS_PROXY,
2828
'local-address': env.npm_config_local_address,
2929
'local-prebuilds': 'prebuilds',
3030
'tag-prefix': 'v',

‎test/asset-test.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
var test = require('tape')
2-
var fs = require('fs')
3-
var rm = require('rimraf')
4-
var path = require('path')
5-
var https = require('https')
6-
var download = require('../download')
7-
var util = require('../util')
8-
var asset = require('../asset')
9-
var nock = require('nock')
10-
var releases = require('./releases.json')
11-
12-
var build = path.join(__dirname, 'build')
13-
var unpacked = path.join(build, 'Release/leveldown.node')
1+
const test = require('tape')
2+
const fs = require('fs')
3+
const rm = require('rimraf')
4+
const path = require('path')
5+
const https = require('https')
6+
const download = require('../download')
7+
const util = require('../util')
8+
const asset = require('../asset')
9+
const nock = require('nock')
10+
const releases = require('./releases.json')
11+
12+
const build = path.join(__dirname, 'build')
13+
const unpacked = path.join(build, 'Release/leveldown.node')
1414

1515
// Release assets call
1616
nock('https://api.github.com:443', {
@@ -37,11 +37,11 @@ nock('https://api.github.com:443', {
3737
})
3838
.reply(302, undefined, {
3939
Location: function (req, res, body) {
40-
var assetId = req.path
40+
const assetId = req.path
4141
.replace('/repos/ralphtheninja/a-native-module/releases/assets/', '')
4242

43-
for (var release of releases) {
44-
for (var asset of release.assets) {
43+
for (const release of releases) {
44+
for (const asset of release.assets) {
4545
if (asset.id.toString() === assetId) {
4646
return asset.browser_download_url
4747
}
@@ -55,16 +55,16 @@ test('downloading from GitHub with token', function (t) {
5555
rm.sync(build)
5656
rm.sync(util.prebuildCache())
5757

58-
var opts = getOpts()
58+
const opts = getOpts()
5959
asset(opts, function (err, assetId) {
6060
t.error(err, 'no error')
6161

62-
var downloadUrl = util.getAssetUrl(opts, assetId)
63-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
64-
var tempFile
62+
const downloadUrl = util.getAssetUrl(opts, assetId)
63+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
64+
let tempFile
6565

66-
var writeStreamCount = 0
67-
var _createWriteStream = fs.createWriteStream
66+
let writeStreamCount = 0
67+
const _createWriteStream = fs.createWriteStream
6868
fs.createWriteStream = function (path) {
6969
if (writeStreamCount++ === 0) {
7070
tempFile = path
@@ -75,13 +75,13 @@ test('downloading from GitHub with token', function (t) {
7575
return _createWriteStream(path)
7676
}
7777

78-
var _createReadStream = fs.createReadStream
78+
const _createReadStream = fs.createReadStream
7979
fs.createReadStream = function (path) {
8080
t.equal(path, cachedPrebuild, 'createReadStream called for cachedPrebuild')
8181
return _createReadStream(path)
8282
}
8383

84-
var _request = https.request
84+
const _request = https.request
8585
https.request = function (req) {
8686
https.request = _request
8787
t.equal('https://' + req.hostname + req.path, downloadUrl, 'correct url')
@@ -107,14 +107,14 @@ test('non existing version should fail asset request', function (t) {
107107
rm.sync(build)
108108
rm.sync(util.prebuildCache())
109109

110-
var opts = getOpts()
110+
const opts = getOpts()
111111
opts.pkg = Object.assign({}, opts.pkg, { version: '0' })
112112
asset(opts, function (err, assetId) {
113113
t.ok(err, 'should error')
114114
t.equal(assetId, undefined)
115115

116-
var downloadUrl = util.getAssetUrl(opts, assetId)
117-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
116+
const downloadUrl = util.getAssetUrl(opts, assetId)
117+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
118118

119119
t.equal(fs.existsSync(cachedPrebuild), false, 'nothing cached')
120120
})

‎test/download-test.js

+51-51
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
var test = require('tape')
2-
var fs = require('fs')
3-
var rm = require('rimraf')
4-
var path = require('path')
5-
var http = require('http')
6-
var https = require('https')
7-
var download = require('../download')
8-
var util = require('../util')
9-
var error = require('../error')
10-
11-
var build = path.join(__dirname, 'build')
12-
var unpacked = path.join(build, 'Release/leveldown.node')
1+
const test = require('tape')
2+
const fs = require('fs')
3+
const rm = require('rimraf')
4+
const path = require('path')
5+
const http = require('http')
6+
const https = require('https')
7+
const download = require('../download')
8+
const util = require('../util')
9+
const error = require('../error')
10+
11+
const build = path.join(__dirname, 'build')
12+
const unpacked = path.join(build, 'Release/leveldown.node')
1313

1414
test('downloading from GitHub, not cached', function (t) {
1515
t.plan(10)
1616
rm.sync(build)
1717
rm.sync(util.prebuildCache())
1818

19-
var opts = getOpts()
20-
var downloadUrl = util.getDownloadUrl(opts)
21-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
22-
var tempFile
19+
const opts = getOpts()
20+
const downloadUrl = util.getDownloadUrl(opts)
21+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
22+
let tempFile
2323

24-
var writeStreamCount = 0
25-
var _createWriteStream = fs.createWriteStream
24+
let writeStreamCount = 0
25+
const _createWriteStream = fs.createWriteStream
2626
fs.createWriteStream = function (path) {
2727
if (writeStreamCount++ === 0) {
2828
tempFile = path
@@ -33,13 +33,13 @@ test('downloading from GitHub, not cached', function (t) {
3333
return _createWriteStream(path)
3434
}
3535

36-
var _createReadStream = fs.createReadStream
36+
const _createReadStream = fs.createReadStream
3737
fs.createReadStream = function (path) {
3838
t.equal(path, cachedPrebuild, 'createReadStream called for cachedPrebuild')
3939
return _createReadStream(path)
4040
}
4141

42-
var _request = https.request
42+
const _request = https.request
4343
https.request = function (opts) {
4444
https.request = _request
4545
t.equal('https://' + opts.hostname + opts.path, downloadUrl, 'correct url')
@@ -63,17 +63,17 @@ test('cached prebuild', function (t) {
6363
t.plan(5)
6464
rm.sync(build)
6565

66-
var opts = getOpts()
67-
var downloadUrl = util.getDownloadUrl(opts)
68-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
66+
const opts = getOpts()
67+
const downloadUrl = util.getDownloadUrl(opts)
68+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
6969

70-
var _createWriteStream = fs.createWriteStream
70+
const _createWriteStream = fs.createWriteStream
7171
fs.createWriteStream = function (path) {
7272
t.ok(/\.node$/i.test(path), 'this is the unpacked file')
7373
return _createWriteStream(path)
7474
}
7575

76-
var _createReadStream = fs.createReadStream
76+
const _createReadStream = fs.createReadStream
7777
fs.createReadStream = function (path) {
7878
t.equal(path, cachedPrebuild, 'createReadStream called for cachedPrebuild')
7979
return _createReadStream(path)
@@ -93,23 +93,23 @@ test('local prebuild', function (t) {
9393
t.plan(6)
9494
rm.sync(build)
9595

96-
var opts = getOpts()
97-
var downloadUrl = util.getDownloadUrl(opts)
98-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
99-
var localPrebuild = util.localPrebuild(downloadUrl, opts)
96+
const opts = getOpts()
97+
const downloadUrl = util.getDownloadUrl(opts)
98+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
99+
const localPrebuild = util.localPrebuild(downloadUrl, opts)
100100

101101
t.ok(fs.existsSync(cachedPrebuild), 'cached prebuild exists')
102102

103103
// fs.copyFileSync() not available before Node 8.5
104104
fs.writeFileSync(localPrebuild, fs.readFileSync(cachedPrebuild))
105105

106-
var _createWriteStream = fs.createWriteStream
106+
const _createWriteStream = fs.createWriteStream
107107
fs.createWriteStream = function (path) {
108108
t.ok(/\.node$/i.test(path), 'this is the unpacked file')
109109
return _createWriteStream(path)
110110
}
111111

112-
var _createReadStream = fs.createReadStream
112+
const _createReadStream = fs.createReadStream
113113
fs.createReadStream = function (path) {
114114
t.equal(path, localPrebuild, 'createReadStream called for localPrebuild')
115115
return _createReadStream(path)
@@ -129,15 +129,15 @@ test('local prebuild', function (t) {
129129
test('non existing host should fail with no dangling temp file', function (t) {
130130
t.plan(3)
131131

132-
var opts = getOpts()
132+
const opts = getOpts()
133133
opts.pkg.binary = {
134134
host: 'https://foo.bar.baz'
135135
}
136136

137-
var downloadUrl = util.getDownloadUrl(opts)
138-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
137+
const downloadUrl = util.getDownloadUrl(opts)
138+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
139139

140-
var _createWriteStream = fs.createWriteStream
140+
const _createWriteStream = fs.createWriteStream
141141
fs.createWriteStream = function (path) {
142142
t.ok(false, 'no temporary file should be written')
143143
return _createWriteStream(path)
@@ -155,17 +155,17 @@ test('non existing host should fail with no dangling temp file', function (t) {
155155
test('existing host but invalid url should fail', function (t) {
156156
t.plan(3)
157157

158-
var opts = getOpts()
158+
const opts = getOpts()
159159
opts.pkg.binary = {
160160
host: 'http://localhost:8888',
161161
remote_path: 'prebuilds',
162162
package_name: 'woohooo-{abi}'
163163
}
164164

165-
var downloadUrl = util.getDownloadUrl(opts)
166-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
165+
const downloadUrl = util.getDownloadUrl(opts)
166+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
167167

168-
var server = http.createServer(function (req, res) {
168+
const server = http.createServer(function (req, res) {
169169
t.equal(req.url, '/prebuilds/woohooo-' + opts.abi, 'correct url')
170170
res.statusCode = 404
171171
res.end()
@@ -182,31 +182,31 @@ test('existing host but invalid url should fail', function (t) {
182182
test('error during download should fail with no dangling temp file', function (t) {
183183
t.plan(7)
184184

185-
var downloadError = new Error('something went wrong during download')
185+
const downloadError = new Error('something went wrong during download')
186186

187-
var opts = getOpts()
187+
const opts = getOpts()
188188
opts.pkg.binary = {
189189
host: 'http://localhost:8889',
190190
remote_path: 'prebuilds',
191191
package_name: 'woohooo-{abi}'
192192
}
193193

194-
var downloadUrl = util.getDownloadUrl(opts)
195-
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
196-
var tempFile
194+
const downloadUrl = util.getDownloadUrl(opts)
195+
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
196+
let tempFile
197197

198-
var _createWriteStream = fs.createWriteStream
198+
const _createWriteStream = fs.createWriteStream
199199
fs.createWriteStream = function (path) {
200200
tempFile = path
201201
t.ok(/\.tmp$/i.test(path), 'this is the temporary file')
202202
return _createWriteStream(path)
203203
}
204204

205-
var _request = http.request
205+
const _request = http.request
206206
http.request = function (opts) {
207207
http.request = _request
208208
t.equal('http://' + opts.hostname + ':' + opts.port + opts.path, downloadUrl, 'correct url')
209-
var wrapped = arguments[1]
209+
const wrapped = arguments[1]
210210
arguments[1] = function (res) {
211211
t.equal(res.statusCode, 200, 'correct statusCode')
212212
// simulates error during download
@@ -216,7 +216,7 @@ test('error during download should fail with no dangling temp file', function (t
216216
return _request.apply(http, arguments)
217217
}
218218

219-
var server = http.createServer(function (req, res) {
219+
const server = http.createServer(function (req, res) {
220220
t.equal(req.url, '/prebuilds/woohooo-' + opts.abi, 'correct url')
221221
res.statusCode = 200
222222
res.write('yep') // simulates hanging request
@@ -233,13 +233,13 @@ test('error during download should fail with no dangling temp file', function (t
233233
})
234234

235235
test('should fail if abi is system abi with invalid binary', function (t) {
236-
var opts = getOpts()
236+
const opts = getOpts()
237237
opts.abi = process.versions.modules
238238
opts.pkg.binary = { host: 'http://localhost:8890' }
239239

240-
var server = http.createServer(function (req, res) {
240+
const server = http.createServer(function (req, res) {
241241
res.statusCode = 200
242-
var archive = path.join(__dirname, 'invalid.tar.gz')
242+
const archive = path.join(__dirname, 'invalid.tar.gz')
243243
fs.createReadStream(archive).pipe(res)
244244
}).listen(8890, function () {
245245
download(util.getDownloadUrl(opts), opts, function (err) {

‎test/log-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
var test = require('tape')
2-
var Logger = require('../log')
1+
const test = require('tape')
2+
const Logger = require('../log')
33

44
test('log.level defaults to notice if npm_config_loglevel is not set', function (t) {
5-
var log = Logger({}, {})
5+
const log = Logger({}, {})
66
t.is(log.level, 'notice')
77
t.end()
88
})
99

1010
test('log.level respects npm_config_loglevel', function (t) {
11-
var log = Logger({}, { npm_config_loglevel: 'info' })
11+
const log = Logger({}, { npm_config_loglevel: 'info' })
1212
t.is(log.level, 'info')
1313
t.end()
1414
})
1515

1616
test('log.level is verbose if rc.verbose', function (t) {
17-
var log = Logger({ verbose: true }, {})
17+
const log = Logger({ verbose: true }, {})
1818
t.is(log.level, 'verbose')
1919
t.end()
2020
})

‎test/proxy-test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
var test = require('tape')
2-
var proxy = require('../proxy')
1+
const test = require('tape')
2+
const proxy = require('../proxy')
33

44
test('downloading using proxy', function (t) {
55
t.plan(8)
66

7-
var opts = {
7+
const opts = {
88
proxy: 'https://user:pass@hostname.com:8080'
99
}
1010

11-
var reqOpts = {
11+
const reqOpts = {
1212
url: 'https://api.github.com/repos/ralphtheninja/a-native-module/releases',
1313
json: true,
1414
headers: {
@@ -17,7 +17,7 @@ test('downloading using proxy', function (t) {
1717
}
1818
}
1919

20-
var request = proxy(reqOpts, opts)
20+
const request = proxy(reqOpts, opts)
2121

2222
t.equal(request.url, reqOpts.url, 'Request url remains the same')
2323
t.equal(request.json, reqOpts.json, 'Request json remains the same')
@@ -33,7 +33,7 @@ test('downloading using proxy', function (t) {
3333
test('downloading without using proxy', function (t) {
3434
t.plan(1)
3535

36-
var reqOpts = {
36+
const reqOpts = {
3737
url: 'https://api.github.com/repos/ralphtheninja/a-native-module/releases',
3838
json: true,
3939
headers: {
@@ -42,6 +42,6 @@ test('downloading without using proxy', function (t) {
4242
}
4343
}
4444

45-
var request = proxy(reqOpts, {})
45+
const request = proxy(reqOpts, {})
4646
t.equal(request.agent, undefined, 'Proxy is not set')
4747
})

‎test/rc-test.js

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var test = require('tape')
2-
var path = require('path')
3-
var exec = require('child_process').exec
4-
var fs = require('fs')
5-
var tempy = require('tempy') // Locked to 0.2.1 for node 6 support
6-
var cleanEnv = require('./util/clean-env')
1+
const test = require('tape')
2+
const path = require('path')
3+
const exec = require('child_process').exec
4+
const fs = require('fs')
5+
const tempy = require('tempy') // Locked to 0.2.1 for node 6 support
6+
const cleanEnv = require('./util/clean-env')
77

88
test('custom config and aliases', function (t) {
9-
var args = [
9+
const args = [
1010
'--arch ARCH',
1111
'--platform PLATFORM',
1212
'--download https://foo.bar',
@@ -45,7 +45,7 @@ test('custom config and aliases', function (t) {
4545

4646
// TODO: merge into above test
4747
test('npm args are passed on from npm environment into rc', function (t) {
48-
var args = [
48+
const args = [
4949
'--build-from-source',
5050
'--download',
5151
'https://foo.bar',
@@ -63,7 +63,7 @@ test('npm args are passed on from npm environment into rc', function (t) {
6363
})
6464

6565
test('npm_config_* are passed on from environment into rc', function (t) {
66-
var env = {
66+
const env = {
6767
// Note that these are validated by npm
6868
npm_config_proxy: 'http://localhost/',
6969
npm_config_https_proxy: 'https://localhost/',
@@ -86,14 +86,14 @@ test('npm_config_* are passed on from environment into rc', function (t) {
8686
})
8787

8888
test('can pass in external package config to rc', function (t) {
89-
var pkg = {
89+
const pkg = {
9090
config: {
9191
target: '1.0.0',
9292
runtime: 'electron',
9393
arch: 'woohoo-arch'
9494
}
9595
}
96-
var rc = require('../rc')(pkg)
96+
const rc = require('../rc')(pkg)
9797
t.equal(rc.target, '1.0.0', 'correct target')
9898
t.equal(rc.runtime, 'electron', 'correct runtime')
9999
t.equal(rc.arch, 'woohoo-arch', 'correct arch')
@@ -108,39 +108,41 @@ test('use default ABI', function (t) {
108108
})
109109

110110
test('using --tag-prefix will set the tag prefix', function (t) {
111-
var args = ['--tag-prefix @scoped/package@']
111+
const args = ['--tag-prefix @scoped/package@']
112112
runRc(t, args.join(' '), {}, function (rc) {
113113
t.equal(rc['tag-prefix'], '@scoped/package@', 'tag prefix should be set')
114114
t.end()
115115
})
116116
})
117117

118118
function runRc (t, args, env, cb) {
119-
var pkg = {
119+
const pkg = {
120120
name: 'test',
121121
private: true,
122122
scripts: {
123123
install: 'node ' + path.resolve(__dirname, '..', 'rc.js') + ' ' + args
124124
}
125125
}
126126

127-
var tmp = tempy.directory()
128-
var json = JSON.stringify(pkg)
127+
const tmp = tempy.directory()
128+
const json = JSON.stringify(pkg)
129129

130130
fs.writeFile(path.join(tmp, 'package.json'), json, function (err) {
131131
if (err) throw err
132132

133-
var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
134-
var cmd = npm + ' run install'
133+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
134+
const cmd = npm + ' run install'
135135

136136
env = Object.assign(cleanEnv(process.env), env)
137137

138138
exec(cmd, { env, cwd: tmp }, function (err, stdout, stderr) {
139139
t.error(err, 'no error')
140140
t.equal(stderr.trim(), '', 'no stderr')
141141

142+
let result
143+
142144
try {
143-
var result = JSON.parse(stdout.slice(stdout.indexOf('{')))
145+
result = JSON.parse(stdout.slice(stdout.indexOf('{')))
144146
} catch (e) {
145147
return t.fail(e)
146148
}

‎test/skip-test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
var test = require('tape')
2-
var path = require('path')
3-
var exec = require('child_process').exec
4-
var execFileSync = require('child_process').execFileSync
5-
var fs = require('fs')
6-
var tempy = require('tempy') // Locked to 0.2.1 for node 6 support
7-
var cleanEnv = require('./util/clean-env')
8-
var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
1+
const test = require('tape')
2+
const path = require('path')
3+
const exec = require('child_process').exec
4+
const execFileSync = require('child_process').execFileSync
5+
const fs = require('fs')
6+
const tempy = require('tempy') // Locked to 0.2.1 for node 6 support
7+
const cleanEnv = require('./util/clean-env')
8+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
99

1010
test('skips download in git dependency', function (t) {
1111
// We're not testing this flag. Just that we do hit the code paths before it
@@ -32,9 +32,9 @@ test('does not skip download in standalone package', function (t) {
3232
})
3333

3434
function run (t, mode, args, cb) {
35-
var addon = tempy.directory()
36-
var logfile = path.join(addon, 'prebuild-install.log')
37-
var cwd = addon
35+
const addon = tempy.directory()
36+
const logfile = path.join(addon, 'prebuild-install.log')
37+
let cwd = addon
3838

3939
writePackage(addon, {
4040
name: 'addon',
@@ -56,7 +56,7 @@ function run (t, mode, args, cb) {
5656
})
5757
}
5858

59-
var env = Object.assign(cleanEnv(process.env), {
59+
const env = Object.assign(cleanEnv(process.env), {
6060
// We shouldn't hit npm or github
6161
npm_config_registry: 'http://localhost:1234',
6262
npm_config_addon_binary_host: 'http://localhost:1234',

‎test/util-test.js

+54-54
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
var test = require('tape')
2-
var fs = require('fs')
3-
var home = require('os').homedir
4-
var util = require('../util')
5-
var path = require('path')
1+
const test = require('tape')
2+
const fs = require('fs')
3+
const home = require('os').homedir
4+
const util = require('../util')
5+
const path = require('path')
66

77
test('prebuildCache() for different environments', function (t) {
8-
var NPMCACHE = process.env.npm_config_cache
8+
const NPMCACHE = process.env.npm_config_cache
99
delete process.env.npm_config_cache
10-
var APPDATA = process.env.APPDATA = 'somepathhere'
10+
const APPDATA = process.env.APPDATA = 'somepathhere'
1111
t.equal(util.prebuildCache(), path.join(APPDATA, '/npm-cache/_prebuilds'), 'APPDATA set')
1212
delete process.env.APPDATA
1313
t.equal(util.prebuildCache(), path.join(home(), '/.npm/_prebuilds'), 'APPDATA not set')
@@ -17,19 +17,19 @@ test('prebuildCache() for different environments', function (t) {
1717
})
1818

1919
test('cachedPrebuild() converts url to valid characters', function (t) {
20-
var url = 'https://github.com/level/leveldown/releases/download/v1.4.0/leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
21-
var tail = 'https-github.com-level-leveldown-releases-download-v1.4.0-leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
22-
var cached = util.cachedPrebuild(url)
20+
const url = 'https://github.com/level/leveldown/releases/download/v1.4.0/leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
21+
const tail = 'https-github.com-level-leveldown-releases-download-v1.4.0-leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
22+
const cached = util.cachedPrebuild(url)
2323
t.ok(cached.indexOf(tail))
2424
t.end()
2525
})
2626

2727
test('tempFile() ends with pid and random number', function (t) {
28-
var url = 'https://github.com/level/leveldown/releases/download/v1.4.0/leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
29-
var cached = util.cachedPrebuild(url)
30-
var tempFile = util.tempFile(cached)
31-
var regexp = /(\S+)\.(\d+)-([a-f0-9]+)\.tmp$/gi
32-
var match = regexp.exec(tempFile)
28+
const url = 'https://github.com/level/leveldown/releases/download/v1.4.0/leveldown-v1.4.0-node-v14-linux-x64.tar.gz'
29+
const cached = util.cachedPrebuild(url)
30+
const tempFile = util.tempFile(cached)
31+
const regexp = /(\S+)\.(\d+)-([a-f0-9]+)\.tmp$/gi
32+
const match = regexp.exec(tempFile)
3333
t.ok(match, 'matches')
3434
t.equal(match[1], cached, 'starts with cached file name')
3535
fs.access(tempFile, fs.R_OK | fs.W_OK, function (err) {
@@ -39,32 +39,32 @@ test('tempFile() ends with pid and random number', function (t) {
3939
})
4040

4141
test('urlTemplate() returns different templates based on pkg and rc', function (t) {
42-
var o1 = { download: 'd0000d' }
43-
var t1 = util.urlTemplate(o1)
42+
const o1 = { download: 'd0000d' }
43+
const t1 = util.urlTemplate(o1)
4444
t.equal(t1, 'd0000d', 'template based on --download <string>')
45-
var o2 = {
45+
const o2 = {
4646
pkg: { binary: { host: 'http://foo.com' } }
4747
}
48-
var t2 = util.urlTemplate(o2)
48+
const t2 = util.urlTemplate(o2)
4949
t.equal(t2, 'http://foo.com/{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz', 'template based on pkg.binary properties')
50-
var o3 = {
50+
const o3 = {
5151
pkg: { binary: { host: 'http://foo.com' } },
5252
download: true
5353
}
54-
var t3 = util.urlTemplate(o3)
54+
const t3 = util.urlTemplate(o3)
5555
t.equal(t3, t2, 'pkg: {} takes precedence over --download')
56-
var o4 = {
56+
const o4 = {
5757
pkg: { binary: { host: 'http://foo.com' } },
5858
download: 'd0000d'
5959
}
60-
var t4 = util.urlTemplate(o4)
60+
const t4 = util.urlTemplate(o4)
6161
t.equal(t4, t1, '--download <string> always goes first')
62-
var o5 = {
62+
const o5 = {
6363
pkg: { binary: { host: 'http://foo.com', remote_path: 'w00t' } }
6464
}
65-
var t5 = util.urlTemplate(o5)
65+
const t5 = util.urlTemplate(o5)
6666
t.equal(t5, 'http://foo.com/w00t/{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz', 'pkg.binary.remote_path is added after host, default format')
67-
var o6 = {
67+
const o6 = {
6868
pkg: {
6969
binary: {
7070
host: 'http://foo.com',
@@ -73,19 +73,19 @@ test('urlTemplate() returns different templates based on pkg and rc', function (
7373
}
7474
}
7575
}
76-
var t6 = util.urlTemplate(o6)
76+
const t6 = util.urlTemplate(o6)
7777
t.equal(t6, 'http://foo.com/w00t/{name}-{major}.{minor}-{runtime}-v{abi}-{platform}-{arch}.tar.gz', 'pkg.binary.package_name is added after host and remote_path, custom format')
78-
var o7 = {
78+
const o7 = {
7979
pkg: require('../package.json'),
8080
download: true
8181
}
8282
delete o7.binary
83-
var envProperty = 'npm_config_' + o7.pkg.name.replace(/[^a-zA-Z0-9]/g, '_') + '_binary_host'
83+
let envProperty = 'npm_config_' + o7.pkg.name.replace(/[^a-zA-Z0-9]/g, '_') + '_binary_host'
8484
process.env[envProperty] = 'http://overriden-url.com/overriden-path'
85-
var t7 = util.urlTemplate(o7)
85+
const t7 = util.urlTemplate(o7)
8686
delete process.env[envProperty]
8787
t.equal(t7, 'http://overriden-url.com/overriden-path/{tag_prefix}{version}/{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz', '--download with host mirror override')
88-
var o8 = {
88+
const o8 = {
8989
pkg: Object.assign({}, require('../package.json'), {
9090
binary: {
9191
host: 'http://foo.com',
@@ -97,18 +97,18 @@ test('urlTemplate() returns different templates based on pkg and rc', function (
9797
}
9898
envProperty += '_mirror'
9999
process.env[envProperty] = 'http://overriden-url.com/overriden-path'
100-
var t8 = util.urlTemplate(o8)
100+
const t8 = util.urlTemplate(o8)
101101
delete process.env[envProperty]
102102
t.equal(t8, 'http://overriden-url.com/overriden-path/{tag_prefix}{version}/{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz', '--download with binary defined and host mirror override')
103-
var o9 = { pkg: require('../package.json'), download: true }
104-
var t9 = util.urlTemplate(o9)
103+
const o9 = { pkg: require('../package.json'), download: true }
104+
const t9 = util.urlTemplate(o9)
105105
t.equal(t9, 'https://github.com/prebuild/prebuild-install/releases/download/{tag_prefix}{version}/{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz', '--download with no arguments, no pkg.binary, no host mirror, default format')
106106
t.end()
107107
})
108108

109109
test('urlTemplate() with pkg.binary cleans up leading ./ or / and trailing /', function (t) {
110-
var expected = 'http://foo.com/w00t/{name}-{major}.{minor}-{runtime}-v{abi}-{platform}-{arch}.tar.gz'
111-
var o = {
110+
const expected = 'http://foo.com/w00t/{name}-{major}.{minor}-{runtime}-v{abi}-{platform}-{arch}.tar.gz'
111+
const o = {
112112
pkg: {
113113
binary: {
114114
host: 'http://foo.com/',
@@ -140,8 +140,8 @@ test('urlTemplate() with pkg.binary cleans up leading ./ or / and trailing /', f
140140
})
141141

142142
test('getDownloadUrl() expands template to correct values', function (t) {
143-
var abi = process.versions.modules
144-
var o1 = {
143+
const abi = process.versions.modules
144+
const o1 = {
145145
pkg: {
146146
name: 'a-native-module',
147147
version: 'x.y.z-alpha5',
@@ -154,9 +154,9 @@ test('getDownloadUrl() expands template to correct values', function (t) {
154154
platform: 'coolplatform',
155155
arch: 'futureplatform'
156156
}
157-
var url1 = util.getDownloadUrl(o1)
157+
const url1 = util.getDownloadUrl(o1)
158158
t.equal(url1, 'https://foo.com/a-native-module-a-native-module-x.y.z-alpha5-x-y-z-alpha5-alpha5-' + abi + '-' + abi + '-coolplatform-futureplatform-Release-a-native-module-bindings', 'weird url but testing everything is propagated, with prerelease and Release')
159-
var o2 = {
159+
const o2 = {
160160
pkg: {
161161
name: 'a-native-module',
162162
version: 'x.y.z+beta77',
@@ -170,9 +170,9 @@ test('getDownloadUrl() expands template to correct values', function (t) {
170170
arch: 'futureplatform',
171171
debug: true
172172
}
173-
var url2 = util.getDownloadUrl(o2)
173+
const url2 = util.getDownloadUrl(o2)
174174
t.equal(url2, 'https://foo.com/a-native-module-a-native-module-x.y.z+beta77-x-y-z+beta77-beta77-' + abi + '-' + abi + '-coolplatform-futureplatform-Debug-a-native-module-bindings', 'weird url but testing everything is propagated, with build and Debug')
175-
var o3 = {
175+
const o3 = {
176176
pkg: {
177177
name: '@scope/a-native-module',
178178
version: 'x.y.z+beta77',
@@ -186,9 +186,9 @@ test('getDownloadUrl() expands template to correct values', function (t) {
186186
arch: 'futureplatform',
187187
debug: true
188188
}
189-
var url3 = util.getDownloadUrl(o3)
189+
const url3 = util.getDownloadUrl(o3)
190190
t.equal(url3, url2, 'scope does not matter for download url')
191-
var o4 = {
191+
const o4 = {
192192
pkg: {
193193
name: '@scope-with.special~chars_/a-native-module',
194194
version: 'x.y.z+beta77',
@@ -202,33 +202,33 @@ test('getDownloadUrl() expands template to correct values', function (t) {
202202
arch: 'futureplatform',
203203
debug: true
204204
}
205-
var url4 = util.getDownloadUrl(o4)
205+
const url4 = util.getDownloadUrl(o4)
206206
t.equal(url4, url2, 'scope with special characters does not matter for download url')
207207
t.end()
208208
})
209209

210210
test('localPrebuild', function (t) {
211-
var envProp = 'npm_config_a_native_module_local_prebuilds'
212-
var basename = 'a-native-module-v1.4.0-node-v14-linux-x64.tar.gz'
213-
var url = 'https://github.com/a-native-module/a-native-module/releases/download/v1.4.0/' + basename
214-
var o1 = {
211+
const envProp = 'npm_config_a_native_module_local_prebuilds'
212+
const basename = 'a-native-module-v1.4.0-node-v14-linux-x64.tar.gz'
213+
const url = 'https://github.com/a-native-module/a-native-module/releases/download/v1.4.0/' + basename
214+
const o1 = {
215215
pkg: {
216216
name: 'a-native-module'
217217
}
218218
}
219-
var path1 = util.localPrebuild(url, o1)
219+
const path1 = util.localPrebuild(url, o1)
220220
t.equal(path1, path.join('prebuilds', basename))
221-
var o2 = {
221+
const o2 = {
222222
pkg: {
223223
name: 'a-native-module'
224224
},
225225
'local-prebuilds': path.join('', 'path', 'to', 'prebuilds')
226226
}
227-
var path2 = util.localPrebuild(url, o2)
227+
const path2 = util.localPrebuild(url, o2)
228228
t.equal(path2, path.join(o2['local-prebuilds'], basename), 'opts overrides default')
229-
var envPrefix = path.join('', 'overriden', 'path', 'to', 'prebuilds')
229+
const envPrefix = path.join('', 'overriden', 'path', 'to', 'prebuilds')
230230
process.env[envProp] = envPrefix
231-
var path3 = util.localPrebuild(url, o2)
231+
const path3 = util.localPrebuild(url, o2)
232232
t.equal(path3, path.join(envPrefix, basename), 'env overrides opts')
233233
t.end()
234234
})

‎test/util/clean-env.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var hasOwnProperty = Object.prototype.hasOwnProperty
1+
const hasOwnProperty = Object.prototype.hasOwnProperty
22

33
module.exports = function (env) {
4-
var clean = {}
4+
const clean = {}
55

6-
for (var k in env) {
6+
for (const k in env) {
77
if (!hasOwnProperty.call(env, k)) continue
88
if (/^npm_/i.test(k)) continue
99

‎util.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
var path = require('path')
2-
var github = require('github-from-package')
3-
var home = require('os').homedir
4-
var crypto = require('crypto')
5-
var expandTemplate = require('expand-template')()
1+
const path = require('path')
2+
const github = require('github-from-package')
3+
const home = require('os').homedir
4+
const crypto = require('crypto')
5+
const expandTemplate = require('expand-template')()
66

77
function getDownloadUrl (opts) {
8-
var pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
8+
const pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
99
return expandTemplate(urlTemplate(opts), {
1010
name: pkgName,
1111
package_name: pkgName,
@@ -40,8 +40,8 @@ function urlTemplate (opts) {
4040
return opts.download
4141
}
4242

43-
var packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz'
44-
var hostMirrorUrl = getHostMirrorUrl(opts)
43+
const packageName = '{name}-v{version}-{runtime}-v{abi}-{platform}{libc}-{arch}.tar.gz'
44+
const hostMirrorUrl = getHostMirrorUrl(opts)
4545

4646
if (hostMirrorUrl) {
4747
return hostMirrorUrl + '/{tag_prefix}{version}/' + packageName
@@ -65,7 +65,7 @@ function getEnvPrefix (pkgName) {
6565
}
6666

6767
function getHostMirrorUrl (opts) {
68-
var propName = getEnvPrefix(opts.pkg.name) + '_binary_host'
68+
const propName = getEnvPrefix(opts.pkg.name) + '_binary_host'
6969
return process.env[propName] || process.env[propName + '_mirror']
7070
}
7171

@@ -74,12 +74,12 @@ function trimSlashes (str) {
7474
}
7575

7676
function cachedPrebuild (url) {
77-
var digest = crypto.createHash('md5').update(url).digest('hex').slice(0, 6)
77+
const digest = crypto.createHash('md5').update(url).digest('hex').slice(0, 6)
7878
return path.join(prebuildCache(), digest + '-' + path.basename(url).replace(/[^a-zA-Z0-9.]+/g, '-'))
7979
}
8080

8181
function npmCache () {
82-
var env = process.env
82+
const env = process.env
8383
return env.npm_config_cache || (env.APPDATA ? path.join(env.APPDATA, 'npm-cache') : path.join(home(), '.npm'))
8484
}
8585

@@ -110,12 +110,12 @@ function packageOrigin (env, pkg) {
110110
}
111111

112112
function localPrebuild (url, opts) {
113-
var propName = getEnvPrefix(opts.pkg.name) + '_local_prebuilds'
114-
var prefix = process.env[propName] || opts['local-prebuilds'] || 'prebuilds'
113+
const propName = getEnvPrefix(opts.pkg.name) + '_local_prebuilds'
114+
const prefix = process.env[propName] || opts['local-prebuilds'] || 'prebuilds'
115115
return path.join(prefix, path.basename(url))
116116
}
117117

118-
var noopLogger = {
118+
const noopLogger = {
119119
http: function () {},
120120
silly: function () {},
121121
debug: function () {},

0 commit comments

Comments
 (0)
Please sign in to comment.