Comparing version 2.7.1 to 2.7.2
@@ -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) {}} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64429
1689
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addednpmlog@2.0.4(transitive)
- Removedare-we-there-yet@1.0.6(transitive)
- Removednpmlog@1.2.1(transitive)
Updatednpmlog@^2.0.0