Skip to content

Commit

Permalink
Bump standard devDependency
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Nov 12, 2021
1 parent 477f347 commit 734ae27
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 265 deletions.
20 changes: 10 additions & 10 deletions asset.js
@@ -1,14 +1,14 @@
var get = require('simple-get')
var util = require('./util')
var proxy = require('./proxy')
const get = require('simple-get')
const util = require('./util')
const proxy = require('./proxy')

function findAssetId (opts, cb) {
var downloadUrl = util.getDownloadUrl(opts)
var apiUrl = util.getApiUrl(opts)
var log = opts.log || util.noopLogger
const downloadUrl = util.getDownloadUrl(opts)
const apiUrl = util.getApiUrl(opts)
const log = opts.log || util.noopLogger

log.http('request', 'GET ' + apiUrl)
var reqOpts = proxy({
const reqOpts = proxy({
url: apiUrl,
json: true,
headers: {
Expand All @@ -17,15 +17,15 @@ function findAssetId (opts, cb) {
}
}, opts)

var req = get.concat(reqOpts, function (err, res, data) {
const req = get.concat(reqOpts, function (err, res, data) {
if (err) return cb(err)
log.http(res.statusCode, apiUrl)
if (res.statusCode !== 200) return cb(err)

// Find asset id in release
for (var release of data) {
for (const release of data) {
if (release.tag_name === opts['tag-prefix'] + opts.pkg.version) {
for (var asset of release.assets) {
for (const asset of release.assets) {
if (asset.browser_download_url === downloadUrl) {
return cb(null, asset.id)
}
Expand Down
26 changes: 13 additions & 13 deletions bin.js
@@ -1,17 +1,17 @@
#!/usr/bin/env node

var path = require('path')
var fs = require('fs')
var napi = require('napi-build-utils')
const path = require('path')
const fs = require('fs')
const napi = require('napi-build-utils')

var pkg = require(path.resolve('package.json'))
var rc = require('./rc')(pkg)
var log = require('./log')(rc, process.env)
var download = require('./download')
var asset = require('./asset')
var util = require('./util')
const pkg = require(path.resolve('package.json'))
const rc = require('./rc')(pkg)
const log = require('./log')(rc, process.env)
const download = require('./download')
const asset = require('./asset')
const util = require('./util')

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

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

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

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

var origin = util.packageOrigin(process.env, pkg)
const origin = util.packageOrigin(process.env, pkg)

if (opts.force) {
log.warn('install', 'prebuilt binaries enforced with --force!')
Expand All @@ -54,7 +54,7 @@ if (opts.force) {
process.exit(1)
}

var startDownload = function (downloadUrl) {
const startDownload = function (downloadUrl) {
download(downloadUrl, opts, function (err) {
if (err) {
log.warn('install', err.message)
Expand Down
44 changes: 22 additions & 22 deletions download.js
@@ -1,19 +1,19 @@
var path = require('path')
var fs = require('fs')
var get = require('simple-get')
var pump = require('pump')
var tfs = require('tar-fs')
var zlib = require('zlib')
var util = require('./util')
var error = require('./error')
var proxy = require('./proxy')
var mkdirp = require('mkdirp-classic')
const path = require('path')
const fs = require('fs')
const get = require('simple-get')
const pump = require('pump')
const tfs = require('tar-fs')
const zlib = require('zlib')
const util = require('./util')
const error = require('./error')
const proxy = require('./proxy')
const mkdirp = require('mkdirp-classic')

function downloadPrebuild (downloadUrl, opts, cb) {
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
var localPrebuild = util.localPrebuild(downloadUrl, opts)
var tempFile = util.tempFile(cachedPrebuild)
var log = opts.log || util.noopLogger
let cachedPrebuild = util.cachedPrebuild(downloadUrl)
const localPrebuild = util.localPrebuild(downloadUrl, opts)
const tempFile = util.tempFile(cachedPrebuild)
const log = opts.log || util.noopLogger

if (opts.nolocal) return download()

Expand All @@ -40,7 +40,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
}

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

if (opts.token) {
reqOpts.headers = {
Expand All @@ -50,7 +50,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
}
}

var req = get(reqOpts, function (err, res) {
const req = get(reqOpts, function (err, res) {
if (err) return onerror(err)
log.http(res.statusCode, downloadUrl)
if (res.statusCode !== 200) return onerror()
Expand Down Expand Up @@ -81,26 +81,26 @@ function downloadPrebuild (downloadUrl, opts, cb) {
}

function unpack () {
var binaryName
let binaryName

var updateName = opts.updateName || function (entry) {
const updateName = opts.updateName || function (entry) {
if (/\.node$/i.test(entry.name)) binaryName = entry.name
}

log.info('unpacking @', cachedPrebuild)

var options = {
const options = {
readable: true,
writable: true,
hardlinkAsFilesFallback: true
}
var extract = tfs.extract(opts.path, options).on('entry', updateName)
const extract = tfs.extract(opts.path, options).on('entry', updateName)

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

var resolved
let resolved
if (binaryName) {
try {
resolved = path.resolve(opts.path || '.', binaryName)
Expand All @@ -124,7 +124,7 @@ function downloadPrebuild (downloadUrl, opts, cb) {
}

function ensureNpmCacheDir (cb) {
var cacheFolder = util.npmCache()
const cacheFolder = util.npmCache()
fs.access(cacheFolder, fs.R_OK | fs.W_OK, function (err) {
if (err && err.code === 'ENOENT') {
return makeNpmCacheDir()
Expand Down
8 changes: 4 additions & 4 deletions log.js
@@ -1,6 +1,6 @@
var log = require('npmlog')
var fs = require('fs')
var path = require('path')
const log = require('npmlog')
const fs = require('fs')
const path = require('path')

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

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

log.on('log', function (msg) {
// Only for tests, don't care about performance
Expand Down
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -3,8 +3,7 @@
"version": "6.1.4",
"description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
"scripts": {
"test": "tape test/*-test.js && npm run lint",
"lint": "standard && hallmark",
"test": "standard && hallmark && tape test/*-test.js",
"hallmark": "hallmark --fix"
},
"keywords": [
Expand Down Expand Up @@ -39,7 +38,7 @@
"hallmark": "^3.0.0",
"nock": "^10.0.6",
"rimraf": "^2.5.2",
"standard": "^13.0.2",
"standard": "^16.0.4",
"tape": "^4.5.1",
"tempy": "0.2.1"
},
Expand Down
20 changes: 10 additions & 10 deletions proxy.js
@@ -1,20 +1,20 @@
var url = require('url')
var tunnel = require('tunnel-agent')
var util = require('./util')
const url = require('url')
const tunnel = require('tunnel-agent')
const util = require('./util')

function applyProxy (reqOpts, opts) {
var log = opts.log || util.noopLogger
const log = opts.log || util.noopLogger

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

if (proxy) {
// eslint-disable-next-line node/no-deprecated-api
var parsedDownloadUrl = url.parse(reqOpts.url)
const parsedDownloadUrl = url.parse(reqOpts.url)
// eslint-disable-next-line node/no-deprecated-api
var parsedProxy = url.parse(proxy)
var uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
var proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
var tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
const parsedProxy = url.parse(proxy)
const uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http')
const proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http')
const tunnelFnName = [uriProtocol, proxyProtocol].join('Over')
reqOpts.agent = tunnel[tunnelFnName]({
proxy: {
host: parsedProxy.hostname,
Expand Down
24 changes: 12 additions & 12 deletions rc.js
@@ -1,18 +1,18 @@
var path = require('path')
var minimist = require('minimist')
var getAbi = require('node-abi').getAbi
var detectLibc = require('detect-libc')
var napi = require('napi-build-utils')
const path = require('path')
const minimist = require('minimist')
const getAbi = require('node-abi').getAbi
const detectLibc = require('detect-libc')
const napi = require('napi-build-utils')

var env = process.env
var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''
const env = process.env
const libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || ''

// Get the configuration
module.exports = function (pkg) {
var pkgConf = pkg.config || {}
var buildFromSource = env.npm_config_build_from_source
const pkgConf = pkg.config || {}
const buildFromSource = env.npm_config_build_from_source

var rc = require('rc')('prebuild-install', {
const rc = require('rc')('prebuild-install', {
target: pkgConf.target || env.npm_config_target || process.versions.node,
runtime: pkgConf.runtime || env.npm_config_runtime || 'node',
arch: pkgConf.arch || env.npm_config_arch || process.arch,
Expand All @@ -23,8 +23,8 @@ module.exports = function (pkg) {
verbose: env.npm_config_verbose === 'true',
buildFromSource: buildFromSource === pkg.name || buildFromSource === 'true',
path: '.',
proxy: env.npm_config_proxy || env['http_proxy'] || env['HTTP_PROXY'],
'https-proxy': env.npm_config_https_proxy || env['https_proxy'] || env['HTTPS_PROXY'],
proxy: env.npm_config_proxy || env.http_proxy || env.HTTP_PROXY,
'https-proxy': env.npm_config_https_proxy || env.https_proxy || env.HTTPS_PROXY,
'local-address': env.npm_config_local_address,
'local-prebuilds': 'prebuilds',
'tag-prefix': 'v',
Expand Down
54 changes: 27 additions & 27 deletions test/asset-test.js
@@ -1,16 +1,16 @@
var test = require('tape')
var fs = require('fs')
var rm = require('rimraf')
var path = require('path')
var https = require('https')
var download = require('../download')
var util = require('../util')
var asset = require('../asset')
var nock = require('nock')
var releases = require('./releases.json')

var build = path.join(__dirname, 'build')
var unpacked = path.join(build, 'Release/leveldown.node')
const test = require('tape')
const fs = require('fs')
const rm = require('rimraf')
const path = require('path')
const https = require('https')
const download = require('../download')
const util = require('../util')
const asset = require('../asset')
const nock = require('nock')
const releases = require('./releases.json')

const build = path.join(__dirname, 'build')
const unpacked = path.join(build, 'Release/leveldown.node')

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

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

var opts = getOpts()
const opts = getOpts()
asset(opts, function (err, assetId) {
t.error(err, 'no error')

var downloadUrl = util.getAssetUrl(opts, assetId)
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
var tempFile
const downloadUrl = util.getAssetUrl(opts, assetId)
const cachedPrebuild = util.cachedPrebuild(downloadUrl)
let tempFile

var writeStreamCount = 0
var _createWriteStream = fs.createWriteStream
let writeStreamCount = 0
const _createWriteStream = fs.createWriteStream
fs.createWriteStream = function (path) {
if (writeStreamCount++ === 0) {
tempFile = path
Expand All @@ -75,13 +75,13 @@ test('downloading from GitHub with token', function (t) {
return _createWriteStream(path)
}

var _createReadStream = fs.createReadStream
const _createReadStream = fs.createReadStream
fs.createReadStream = function (path) {
t.equal(path, cachedPrebuild, 'createReadStream called for cachedPrebuild')
return _createReadStream(path)
}

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

var opts = getOpts()
const opts = getOpts()
opts.pkg = Object.assign({}, opts.pkg, { version: '0' })
asset(opts, function (err, assetId) {
t.ok(err, 'should error')
t.equal(assetId, undefined)

var downloadUrl = util.getAssetUrl(opts, assetId)
var cachedPrebuild = util.cachedPrebuild(downloadUrl)
const downloadUrl = util.getAssetUrl(opts, assetId)
const cachedPrebuild = util.cachedPrebuild(downloadUrl)

t.equal(fs.existsSync(cachedPrebuild), false, 'nothing cached')
})
Expand Down

0 comments on commit 734ae27

Please sign in to comment.