Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

prebuild

Package Overview
Dependencies
Maintainers
2
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prebuild - npm Package Compare versions

Comparing version 2.7.1 to 2.7.2

31

download.js

@@ -23,3 +23,3 @@ var path = require('path')

if (exists) {
log.info('found. unpacking...')
log.info('found local prebuild')
cachedPrebuild = localPrebuild

@@ -29,3 +29,2 @@ return unpack()

log.info('not found. downloading...')
download()

@@ -38,4 +37,8 @@ })

log.info('looking for cached prebuild @', cachedPrebuild)
fs.exists(cachedPrebuild, function (exists) {
if (exists) return unpack()
if (exists) {
log.info('found cached prebuild')
return unpack()
}

@@ -48,2 +51,3 @@ log.http('request', 'GET ' + downloadUrl)

fs.mkdir(util.prebuildCache(), function () {
log.info('downloading to @', tempFile)
pump(res, fs.createWriteStream(tempFile), function (err) {

@@ -53,2 +57,3 @@ if (err) return onerror(err)

if (err) return cb(err)
log.info('renaming to @', cachedPrebuild)
unpack()

@@ -80,15 +85,15 @@ })

log.info('unpacking @', cachedPrebuild)
pump(fs.createReadStream(cachedPrebuild), zlib.createGunzip(), tfs.extract(rc.path, {readable: true, writable: true}).on('entry', updateName), function (err) {
if (err) return cb(err)
if (binaryName) {
try {
var resolved = path.resolve(rc.path || '.', binaryName)
require(resolved)
log.info('unpack', 'required ' + resolved + ' successfully')
} catch (err) {
return cb(err)
}
return cb()
if (!binaryName) return cb(new Error('Missing .node file in archive'))
var resolved
try {
resolved = path.resolve(rc.path || '.', binaryName)
require(resolved)
} catch (err) {
return cb(err)
}
cb(new Error('Missing .node file in archive'))
log.info('unpack', 'required ' + resolved + ' successfully')
cb(null, resolved)
})

@@ -95,0 +100,0 @@ }

{
"name": "prebuild",
"version": "2.7.1",
"version": "2.7.2",
"description": "A command line tool for easily doing prebuilds for multiple version of node/iojs on a specific platform",

@@ -28,3 +28,3 @@ "scripts": {

"node-gyp": "^3.0.3",
"npmlog": "^1.2.1",
"npmlog": "^2.0.0",
"pump": "^1.0.0",

@@ -39,3 +39,3 @@ "rc": "^1.0.3",

"rimraf": "^2.4.2",
"standard": "~5.3.1",
"standard": "~5.4.1",
"tape": "^4.0.1",

@@ -42,0 +42,0 @@ "xtend": "^4.0.0"

@@ -7,3 +7,2 @@ var test = require('tape')

var util = require('../util')
var pkg = require('a-native-module/package')
var http = require('http')

@@ -16,28 +15,7 @@ var https = require('https')

test('downloading from GitHub, not cached', function (t) {
t.plan(20)
t.plan(14)
rm.sync(build)
rm.sync(util.prebuildCache())
var requestCount = 0
var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch, path: __dirname},
log: {
http: function (type, message) {
if (requestCount++ === 0) {
t.equal(type, 'request', 'http request')
t.equal(message, 'GET ' + downloadUrl)
} else {
t.equal(type, 200, 'status code logged')
t.equal(message, downloadUrl)
}
},
info: function (type, message) {
t.equal(type, 'unpack', 'required module successfully')
t.equal(message, 'required ' + unpacked + ' successfully')
}
}
}
var opts = getOpts()
var downloadUrl = util.getDownloadUrl(opts)

@@ -124,17 +102,6 @@ var cachedPrebuild = util.cachedPrebuild(downloadUrl)

test('cached prebuild', function (t) {
t.plan(10)
t.plan(8)
rm.sync(build)
var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch, path: __dirname},
log: {
info: function (type, message) {
t.equal(type, 'unpack', 'required module successfully')
t.equal(message, 'required ' + unpacked + ' successfully')
}
}
}
var opts = getOpts()
var downloadUrl = util.getDownloadUrl(opts)

@@ -195,11 +162,6 @@ var cachedPrebuild = util.cachedPrebuild(downloadUrl)

var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch, path: __dirname},
updateName: function (entry) {
t.ok(/\.node$/i.test(entry.name), 'should match but we pretend it does not')
}
var opts = getOpts()
opts.updateName = function (entry) {
t.ok(/\.node$/i.test(entry.name), 'should match but we pretend it does not')
}
download(opts, function (err) {

@@ -212,15 +174,5 @@ t.equal(err.message, 'Missing .node file in archive', 'correct error message')

test('non existing host should fail with no dangling temp file', function (t) {
t.plan(5)
t.plan(3)
var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch},
log: {
http: function (type, message) {
t.equal(type, 'request', 'http request')
t.equal(message, 'GET ' + downloadUrl)
}
}
}
var opts = getOpts()
opts.pkg.binary = {

@@ -249,22 +201,5 @@ host: 'https://foo.bar.baz'

test('existing host but invalid url should fail', function (t) {
t.plan(7)
t.plan(3)
var requestCount = 0
var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch},
log: {
http: function (type, message) {
if (requestCount >= 2) return
if (requestCount++ === 0) {
t.equal(type, 'request', 'http request')
t.equal(message, 'GET ' + downloadUrl)
} else {
t.equal(type, 404, 'invalid resource')
t.equal(message, downloadUrl)
}
}
}
}
var opts = getOpts()
opts.pkg.binary = {

@@ -297,8 +232,4 @@ host: 'http://localhost:8888',

var downloadError = new Error('something went wrong during download')
var opts = {
pkg: pkg,
nolocal: true,
rc: {platform: process.platform, arch: process.arch},
log: {http: function () { }}
}
var opts = getOpts()
opts.pkg.binary = {

@@ -350,1 +281,10 @@ host: 'http://localhost:8889',

})
function getOpts () {
return {
pkg: require('a-native-module/package'),
nolocal: true,
rc: {platform: process.platform, arch: process.arch, path: __dirname},
log: {http: function (type, message) {}, info: function (type, message) {}}
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc