Socket
Socket
Sign inDemoInstall

prebuild-install

Package Overview
Dependencies
59
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

93

download.js

@@ -18,72 +18,55 @@ var path = require('path')

var cachedPrebuild = util.cachedPrebuild(downloadUrl)
var localPrebuild = util.localPrebuild(downloadUrl)
var tempFile = util.tempFile(cachedPrebuild)
var log = opts.log || noop
if (opts.nolocal) return download()
ensureNpmCacheDir(function (err) {
if (err) return onerror(err)
log.info('looking for local prebuild @', localPrebuild)
fs.access(localPrebuild, fs.R_OK | fs.W_OK, function (err) {
if (err && err.code === 'ENOENT') {
return download()
}
log.info('looking for cached prebuild @', cachedPrebuild)
fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
if (!(err && err.code === 'ENOENT')) {
log.info('found cached prebuild')
return unpack()
}
log.info('found local prebuild')
cachedPrebuild = localPrebuild
unpack()
})
log.http('request', 'GET ' + downloadUrl)
var reqOpts = proxy({ url: downloadUrl }, opts)
function download () {
ensureNpmCacheDir(function (err) {
if (err) return onerror(err)
log.info('looking for cached prebuild @', cachedPrebuild)
fs.access(cachedPrebuild, fs.R_OK | fs.W_OK, function (err) {
if (!(err && err.code === 'ENOENT')) {
log.info('found cached prebuild')
return unpack()
if (opts.token) {
reqOpts.url += '?access_token=' + opts.token
reqOpts.headers = {
'User-Agent': 'simple-get',
'Accept': 'application/octet-stream'
}
}
log.http('request', 'GET ' + downloadUrl)
var reqOpts = proxy({ url: downloadUrl }, opts)
if (opts.token) {
reqOpts.url += '?access_token=' + opts.token
reqOpts.headers = {
'User-Agent': 'simple-get',
'Accept': 'application/octet-stream'
}
}
var req = get(reqOpts, function (err, res) {
if (err) return onerror(err)
log.http(res.statusCode, downloadUrl)
if (res.statusCode !== 200) return onerror()
mkdirp(util.prebuildCache(), function () {
log.info('downloading to @', tempFile)
pump(res, fs.createWriteStream(tempFile), function (err) {
if (err) return onerror(err)
fs.rename(tempFile, cachedPrebuild, function (err) {
if (err) return cb(err)
log.info('renaming to @', cachedPrebuild)
unpack()
})
var req = get(reqOpts, function (err, res) {
if (err) return onerror(err)
log.http(res.statusCode, downloadUrl)
if (res.statusCode !== 200) return onerror()
mkdirp(util.prebuildCache(), function () {
log.info('downloading to @', tempFile)
pump(res, fs.createWriteStream(tempFile), function (err) {
if (err) return onerror(err)
fs.rename(tempFile, cachedPrebuild, function (err) {
if (err) return cb(err)
log.info('renaming to @', cachedPrebuild)
unpack()
})
})
})
})
req.setTimeout(30 * 1000, function () {
req.abort()
})
req.setTimeout(30 * 1000, function () {
req.abort()
})
function onerror (err) {
fs.unlink(tempFile, function () {
cb(err || error.noPrebuilts(opts))
})
}
})
}
function onerror (err) {
fs.unlink(tempFile, function () {
cb(err || error.noPrebuilts(opts))
})
}
})
function unpack () {

@@ -90,0 +73,0 @@ var binaryName

{
"name": "prebuild-install",
"version": "3.0.0",
"description": "A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform",
"version": "4.0.0",
"description": "A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform",
"scripts": {

@@ -50,3 +50,3 @@ "test": "verify-travis-appveyor && tape test/*-test.js && npm run audit && npm run lint",

"type": "git",
"url": "https://github.com/mafintosh/prebuild-install.git"
"url": "https://github.com/prebuild/prebuild-install.git"
},

@@ -65,5 +65,8 @@ "author": "Mathias Buus (@mafintosh)",

"bugs": {
"url": "https://github.com/mafintosh/prebuild-install/issues"
"url": "https://github.com/prebuild/prebuild-install/issues"
},
"homepage": "https://github.com/mafintosh/prebuild-install"
"homepage": "https://github.com/prebuild/prebuild-install",
"engines": {
"node": ">=4"
}
}
# prebuild-install
> A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform.
[![npm](https://img.shields.io/npm/v/prebuild-install.svg)](https://www.npmjs.com/package/prebuild-install)
![Node version](https://img.shields.io/node/v/prebuild-install.svg)
[![Build Status](https://travis-ci.org/prebuild/prebuild-install.svg?branch=master)](https://travis-ci.org/prebuild/prebuild-install)

@@ -8,4 +12,2 @@ [![Build status](https://ci.appveyor.com/api/projects/status/6v6hxxwgjrr99pc8/branch/master?svg=true)](https://ci.appveyor.com/project/mathiask88/prebuild-install)

> A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform.
`prebuild-install` supports installing prebuilt binaries from GitHub by default.

@@ -16,8 +18,8 @@

Change your package.json install script to:
```
...
```json
{
"scripts": {
"install": "prebuild-install || node-gyp rebuild"
}
...
}
```

@@ -27,3 +29,3 @@

You need to provide prebuilds made by [prebuild](https://github.com/mafintosh/prebuild).
You need to provide prebuilds made by [`prebuild`](https://github.com/prebuild/prebuild).

@@ -92,4 +94,12 @@ ### Help

### Cache
All prebuilt binaries are cached to minimize traffic. So first `prebuild-install` picks binaries from the cache and if no binary could be found, it will be downloaded. Depending on the environment, the cache folder is determined in the following order:
* `${npm_config_cache}/_prebuilds`
* `${APP_DATA}/npm-cache/_prebuilds`
* `${HOME}/.npm/_prebuilds`
## License
MIT
var path = require('path')
var github = require('github-from-package')
var home = require('os-homedir')
var crypto = require('crypto')
var expandTemplate = require('expand-template')()

@@ -71,3 +72,4 @@

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

@@ -88,6 +90,2 @@

function localPrebuild (url) {
return path.join('prebuilds', path.basename(url))
}
exports.getDownloadUrl = getDownloadUrl

@@ -98,5 +96,4 @@ exports.getApiUrl = getApiUrl

exports.cachedPrebuild = cachedPrebuild
exports.localPrebuild = localPrebuild
exports.prebuildCache = prebuildCache
exports.npmCache = npmCache
exports.tempFile = tempFile
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc