Comparing version 2.5.5 to 2.6.0
@@ -9,7 +9,7 @@ var gypinstall = require('./gypinstall') | ||
tryReadFiles(function(err, abi) { | ||
tryReadFiles(function (err, abi) { | ||
if (err && err.code === 'ENOENT') { | ||
return install({log: log, force: true}, version, function (err) { | ||
if (err) return cb(err) | ||
tryReadFiles(function(err, abi) { | ||
tryReadFiles(function (err, abi) { | ||
if (!err || err.code !== 'ENOENT') return cb(err, abi) | ||
@@ -24,3 +24,3 @@ cb(new Error('Failed to locate `node.h` and `node_version.h`.')) | ||
function tryReadFiles(readCb) { | ||
function tryReadFiles (readCb) { | ||
util.readGypFile(version, 'node_version.h', function (err, a) { | ||
@@ -39,3 +39,3 @@ if (err) return readCb(err) | ||
var res = file.match(/#define\s+NODE_MODULE_VERSION\s+\(?(\d+)/) | ||
return res && res[1] | ||
return (res && res[1]) | ||
} | ||
@@ -42,0 +42,0 @@ } |
66
bin.js
@@ -39,8 +39,12 @@ #!/usr/bin/env node | ||
if (rc.compile) return build(opts, process.version, onbuilderror) | ||
if (rc.download) { | ||
return download({pkg: pkg, rc: rc, log: log}, function (err) { | ||
if (rc.compile) { | ||
build(opts, process.version, onbuilderror) | ||
} else if (rc.download) { | ||
download({pkg: pkg, rc: rc, log: log}, function (err) { | ||
if (err) { | ||
log.warn('install', err.message) | ||
if (rc.compile === false) { | ||
log.info('install', 'no-compile specified, not attempting build.') | ||
return | ||
} | ||
log.info('install', 'We will now try to compile from source.') | ||
@@ -51,31 +55,31 @@ return build(opts, process.version, onbuilderror) | ||
}) | ||
} | ||
var files = [] | ||
async.eachSeries([].concat(rc.target), function (target, next) { | ||
prebuild(opts, target, function (err, tarGz) { | ||
if (err) return next(err) | ||
files.push(tarGz) | ||
next() | ||
}) | ||
}, function (err) { | ||
if (err) return onbuilderror(err) | ||
if (!rc.upload) return | ||
buildLog('Uploading ' + files.length + ' prebuilds(s) to Github releases') | ||
upload({pkg: pkg, rc: rc, files: files}, function (err, result) { | ||
} else { | ||
var files = [] | ||
async.eachSeries([].concat(rc.target), function (target, next) { | ||
prebuild(opts, target, function (err, tarGz) { | ||
if (err) return next(err) | ||
files.push(tarGz) | ||
next() | ||
}) | ||
}, function (err) { | ||
if (err) return onbuilderror(err) | ||
buildLog('Found ' + result.old.length + ' prebuild(s) on Github') | ||
if (result.old.length) { | ||
result.old.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
buildLog('Uploaded ' + result.new.length + ' new prebuild(s) to Github') | ||
if (result.new.length) { | ||
result.new.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
if (!rc.upload) return | ||
buildLog('Uploading ' + files.length + ' prebuilds(s) to Github releases') | ||
upload({pkg: pkg, rc: rc, files: files}, function (err, result) { | ||
if (err) return onbuilderror(err) | ||
buildLog('Found ' + result.old.length + ' prebuild(s) on Github') | ||
if (result.old.length) { | ||
result.old.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
buildLog('Uploaded ' + result.new.length + ' new prebuild(s) to Github') | ||
if (result.new.length) { | ||
result.new.forEach(function (build) { | ||
buildLog('-> ' + build) | ||
}) | ||
} | ||
}) | ||
}) | ||
}) | ||
} | ||
@@ -82,0 +86,0 @@ function onbuilderror (err) { |
var path = require('path') | ||
var fs = require('fs') | ||
var gypinstall = require('./gypinstall') | ||
var releaseFolder = require('./util').releaseFolder | ||
var runGyp = require('./gyp') | ||
var gypbuild = require('./gypbuild') | ||
@@ -12,3 +11,3 @@ function build (opts, version, cb) { | ||
log.verbose('starting node-gyp process') | ||
runGyp(opts, version, function (err) { | ||
gypbuild(opts, version, function (err) { | ||
if (err) return cb(err) | ||
@@ -23,4 +22,5 @@ log.verbose('done node-gyp\'ing') | ||
for (var i = 0; i < files.length; i++) { | ||
if (/\.node$/i.test(files[i])) | ||
if (/\.node$/i.test(files[i])) { | ||
return cb(null, path.join(release, files[i]), files[i]) | ||
} | ||
} | ||
@@ -27,0 +27,0 @@ cb(new Error('Could not find build in ' + release)) |
@@ -12,38 +12,58 @@ var path = require('path') | ||
var cachedPrebuild = util.cachedPrebuild(downloadUrl) | ||
var localPrebuild = util.localPrebuild(downloadUrl) | ||
var tempFile = util.tempFile(cachedPrebuild) | ||
var pkg = opts.pkg | ||
var rc = opts.rc | ||
var log = opts.log | ||
fs.exists(cachedPrebuild, function (exists) { | ||
if (exists) return unpack() | ||
if (opts.nolocal) return download() | ||
log.http('request', 'GET ' + downloadUrl) | ||
var req = get(downloadUrl, function (err, res) { | ||
log.info('looking for local prebuild @', localPrebuild) | ||
fs.exists(localPrebuild, function (exists) { | ||
if (exists) { | ||
log.info('found. unpacking...') | ||
cachedPrebuild = localPrebuild | ||
return unpack() | ||
} | ||
log.info('not found. downloading...') | ||
download() | ||
}) | ||
function download () { | ||
ensureNpmCacheDir(function (err) { | ||
if (err) return onerror(err) | ||
log.http(res.statusCode, downloadUrl) | ||
if (res.statusCode !== 200) return onerror() | ||
fs.mkdir(util.prebuildCache(), function () { | ||
pump(res, fs.createWriteStream(tempFile), function (err) { | ||
fs.exists(cachedPrebuild, function (exists) { | ||
if (exists) return unpack() | ||
log.http('request', 'GET ' + downloadUrl) | ||
var req = get(downloadUrl, function (err, res) { | ||
if (err) return onerror(err) | ||
fs.rename(tempFile, cachedPrebuild, function (err) { | ||
if (err) return cb(err) | ||
unpack() | ||
log.http(res.statusCode, downloadUrl) | ||
if (res.statusCode !== 200) return onerror() | ||
fs.mkdir(util.prebuildCache(), function () { | ||
pump(res, fs.createWriteStream(tempFile), function (err) { | ||
if (err) return onerror(err) | ||
fs.rename(tempFile, cachedPrebuild, function (err) { | ||
if (err) return cb(err) | ||
unpack() | ||
}) | ||
}) | ||
}) | ||
}) | ||
req.setTimeout(30 * 1000, function () { | ||
req.abort() | ||
}) | ||
}) | ||
}) | ||
req.setTimeout(30 * 1000, function () { | ||
req.abort() | ||
function onerror (err) { | ||
fs.unlink(tempFile, function () { | ||
cb(err || new Error('Prebuilt binaries for node version ' + process.version + ' are not available')) | ||
}) | ||
} | ||
}) | ||
} | ||
function onerror (err) { | ||
fs.unlink(tempFile, function () { | ||
cb(err || new Error('Prebuilt binaries for node version ' + process.version + ' are not available')) | ||
}) | ||
} | ||
}) | ||
function unpack () { | ||
@@ -71,4 +91,30 @@ var binaryName | ||
} | ||
function ensureNpmCacheDir (cb) { | ||
var cacheFolder = util.npmCache() | ||
if (fs.access) { | ||
fs.access(cacheFolder, fs.R_OK | fs.W_OK, function (err) { | ||
if (err && err.code === 'ENOENT') { | ||
return makeNpmCacheDir() | ||
} | ||
if (err) return cb(err) | ||
cb() | ||
}) | ||
} else { | ||
fs.exists(cacheFolder, function (exists) { | ||
if (!exists) return makeNpmCacheDir() | ||
cb() | ||
}) | ||
} | ||
function makeNpmCacheDir () { | ||
log.info('npm cache directory missing, creating it...') | ||
fs.mkdir(cacheFolder, function (err) { | ||
if (err) return cb(err) | ||
cb() | ||
}) | ||
} | ||
} | ||
} | ||
module.exports = downloadPrebuild |
72
gyp.js
var nodeGyp = require('node-gyp')() | ||
var util = require('./util') | ||
function runGyp (opts, version, cb) { | ||
function runGyp (opts, cb) { | ||
var gyp = opts.gyp || nodeGyp | ||
var log = opts.log | ||
if (!opts.rc.preinstall) return run() | ||
log.verbose('executing preinstall') | ||
util.spawn(opts.rc.preinstall, function (err) { | ||
if (err) return cb(err) | ||
run() | ||
}) | ||
log.verbose('execute node-gyp with `' + opts.args.join(' ') + '`') | ||
gyp.parseArgv(opts.args) | ||
function run () { | ||
log.verbose('preparing nodegyp rebuild') | ||
var args = ['node', 'index.js', 'rebuild', '--target=' + version, '--target_arch=' + opts.rc.arch] | ||
if (opts.rc.debug) args.push('--debug') | ||
gyp.parseArgv(args) | ||
function runStep () { | ||
var command = gyp.todo.shift() | ||
if (!command) { | ||
return cb() | ||
} | ||
function runStep () { | ||
var command = gyp.todo.shift() | ||
if (!command) { | ||
return cb() | ||
if (opts.filter) { | ||
if (opts.filter(command)) { | ||
process.nextTick(runStep) | ||
return | ||
} | ||
} | ||
if (command.name === 'configure') configurePreGyp(command, opts) | ||
gyp.commands[command.name](command.args, function (err) { | ||
if (err) { | ||
log.error(command.name + ' error') | ||
log.error('stack', err.stack) | ||
log.error('not ok') | ||
return cb(err) | ||
} | ||
log.verbose('performing nodegyp rebuild cmd', command.name, command.args) | ||
gyp.commands[command.name](command.args, function(err) { | ||
if (err) { | ||
log.error(command.name + ' error') | ||
log.error('stack', err.stack) | ||
log.error('not ok') | ||
return cb(err) | ||
} | ||
// Log that the command completed properly | ||
log.verbose('ok') | ||
// Log that the command completed properly | ||
log.verbose('ok') | ||
// now run the next command in the queue | ||
process.nextTick(runStep) | ||
}) | ||
} | ||
// now run the next command in the queue | ||
process.nextTick(runStep) | ||
}) | ||
} | ||
if (gyp.todo.length > 0) { | ||
runStep() | ||
} else { | ||
log.verbose('no gyp tasks needed') | ||
cb() | ||
} | ||
} | ||
function configurePreGyp (command, opts) { | ||
var binary = opts.pkg.binary | ||
if (binary && binary.module_name) { | ||
command.args.push('-Dmodule_name=' + binary.module_name) | ||
} | ||
if (binary && binary.module_path) { | ||
command.args.push('-Dmodule_path=' + binary.module_path) | ||
} | ||
} | ||
module.exports = runGyp |
@@ -1,36 +0,11 @@ | ||
var nodeGyp = require('node-gyp')() | ||
var gyp = require('./gyp') | ||
function runGypInstall (opts, version, cb) { | ||
var gyp = opts.gyp || nodeGyp | ||
var log = opts.log | ||
log.verbose('preparing nodegyp install') | ||
var args = ['node', 'index.js', 'install', version] | ||
gyp.parseArgv(args) | ||
function runStep () { | ||
var command = gyp.todo.shift() | ||
if (!command) { | ||
return cb() | ||
} | ||
log.verbose('performing nodegyp install cmd', command.name, command.args) | ||
gyp.commands[command.name](command.args, function(err) { | ||
if (err) { | ||
log.error(command.name + ' error') | ||
log.error('stack', err.stack) | ||
log.error('not ok') | ||
return cb(err) | ||
} | ||
// Log that the command completed properly | ||
log.verbose('ok') | ||
// now run the next command in the queue | ||
process.nextTick(runStep) | ||
}) | ||
} | ||
runStep() | ||
gyp({ | ||
gyp: opts.gyp, | ||
log: opts.log, | ||
args: ['node', 'index.js', 'install', version] | ||
}, cb) | ||
} | ||
module.exports = runGypInstall |
@@ -9,2 +9,3 @@ prebuild [options] | ||
--compile, -c (compile your project using node-gyp) | ||
--no-compile (skip compile fallback when downloading) | ||
--strip (strip debug information) | ||
@@ -11,0 +12,0 @@ --debug (set Debug or Release configuration) |
@@ -7,2 +7,6 @@ var fs = require('fs') | ||
function mode (octal) { | ||
return parseInt(octal, 8) | ||
} | ||
function pack (filename, tarPath, cb) { | ||
@@ -18,3 +22,3 @@ mkdirp(path.dirname(tarPath), function () { | ||
size: st.size, | ||
mode: st.mode | 0444 | 0222, | ||
mode: st.mode | mode('444') | mode('222'), | ||
gid: st.gid, | ||
@@ -21,0 +25,0 @@ uid: st.uid |
{ | ||
"name": "prebuild", | ||
"version": "2.5.5", | ||
"version": "2.6.0", | ||
"description": "A command line tool for easily doing prebuilds for multiple version of node/iojs on a specific platform", | ||
"scripts": { | ||
"test": "tape test/*-test.js" | ||
"test": "standard && tape test/*-test.js" | ||
}, | ||
@@ -27,2 +27,3 @@ "dependencies": { | ||
"rimraf": "^2.4.2", | ||
"standard": "~5.3.1", | ||
"tape": "^4.0.1" | ||
@@ -29,0 +30,0 @@ }, |
var fs = require('fs') | ||
var path = require('path') | ||
var async = require('async') | ||
@@ -42,12 +41,14 @@ var getAbi = require('./abi') | ||
if (rc.strip) tasks.splice(1, 0, function (filename, cb) { | ||
buildLog('Stripping debug information from ' + filename) | ||
strip(filename, function (err) { | ||
if (err) return cb(err) | ||
cb(null, filename) | ||
if (rc.strip) { | ||
tasks.splice(1, 0, function (filename, cb) { | ||
buildLog('Stripping debug information from ' + filename) | ||
strip(filename, function (err) { | ||
if (err) return cb(err) | ||
cb(null, filename) | ||
}) | ||
}) | ||
}) | ||
} | ||
// TODO if we can move out buildLog() to the caller, we can simply do | ||
//async.waterfall(tasks, callback) | ||
// async.waterfall(tasks, callback) | ||
async.waterfall(tasks, function (err) { | ||
@@ -54,0 +55,0 @@ if (err) return callback(err) |
45
rc.js
var minimist = require('minimist') | ||
if (process.env.npm_config_argv) { | ||
var npmargs = [ | ||
'compile', | ||
'no-build-from-source', | ||
'debug' | ||
] | ||
try { | ||
var npm_argv = JSON.parse(process.env.npm_config_argv).cooked | ||
for (var i = 0; i < npmargs.length; ++i) { | ||
if (npm_argv.indexOf('--' + npmargs[i]) !== -1) { | ||
process.argv.push('--' + npmargs[i]) | ||
} | ||
if (npm_argv.indexOf('--no-' + npmargs[i]) !== -1) { | ||
process.argv.push('--no-' + npmargs[i]) | ||
} | ||
} | ||
} catch (e) { } | ||
var npmconfigs = [ | ||
'proxy', | ||
'https-proxy', | ||
'local-address' | ||
] | ||
for (var j = 0; j < npmconfigs.length; ++j) { | ||
var envname = 'npm_config_' + npmconfigs[j].replace('-', '_') | ||
if (process.env[envname]) { | ||
process.argv.push('--' + npmconfigs[j]) | ||
process.argv.push(process.env[envname]) | ||
} | ||
} | ||
} | ||
module.exports = require('rc')('prebuild', { | ||
@@ -7,6 +39,7 @@ target: process.version, | ||
platform: process.platform, | ||
compile: npmConfig('--build-from-source'), | ||
force: npmConfig('--force'), | ||
debug: npmConfig('--debug'), | ||
path: '.' | ||
force: false, | ||
debug: false, | ||
path: '.', | ||
proxy: process.env['HTTP_PROXY'], | ||
'https-proxy': process.env['HTTPS_PROXY'] | ||
}, minimist(process.argv, { | ||
@@ -28,8 +61,4 @@ alias: { | ||
function npmConfig (argv) { | ||
return !!(process.env.npm_config_argv && process.env.npm_config_argv.indexOf(argv) > -1) | ||
} | ||
if (!module.parent) { | ||
console.log('%j', module.exports) | ||
} |
@@ -55,4 +55,3 @@ # prebuild | ||
If no suitable binary is found for the current platform / node version `prebuild` | ||
will simply fallback to run `node-gyp rebuild`. | ||
If no suitable binary is found for the current platform / node version, `prebuild` will fallback to `node-gyp rebuild`. Native modules that have a javascript fallback can use `--no-compile` to prevent this. | ||
@@ -134,2 +133,3 @@ Once a binary has been downloaded `prebuild` will `require()` the module and if that fails it will also fallback to building it. | ||
--compile, -c (compile your project using node-gyp) | ||
--no-compile (skip compile fallback when downloading) | ||
--strip (strip debug information) | ||
@@ -136,0 +136,0 @@ --debug (set Debug or Release configuration) |
@@ -14,4 +14,3 @@ var test = require('tape') | ||
process.nextTick(cb.bind(null, null, '#define NODE_MODULE_VERSION 666')) | ||
} | ||
else { | ||
} else { | ||
t.equal(file, 'node.h', 'correct file') | ||
@@ -22,2 +21,3 @@ process.nextTick(cb.bind(null, null, '#define NODE_MODULE_VERSION 314')) | ||
getAbi({}, v, function (err, abi) { | ||
t.error(err, 'getAbi should not fail') | ||
t.equal(abi, '666', 'abi version taken from src/node_version.h') | ||
@@ -36,4 +36,3 @@ util.readGypFile = _readGypFile | ||
process.nextTick(cb.bind(null, null, 'no proper define here!')) | ||
} | ||
else { | ||
} else { | ||
process.nextTick(cb.bind(null, null, '#define NODE_MODULE_VERSION 314')) | ||
@@ -43,2 +42,3 @@ } | ||
getAbi({}, v, function (err, abi) { | ||
t.error(err, 'getAbi should not fail') | ||
t.equal(abi, '314', 'abi version taken from src/node.h') | ||
@@ -64,3 +64,3 @@ util.readGypFile = _readGypFile | ||
test('missing src/node_version.h will run node-gyp-install and retry', function (t) { | ||
t.plan(4) | ||
t.plan(5) | ||
var readCount = 0 | ||
@@ -72,4 +72,3 @@ var v = 'vX.Y.Z' | ||
process.nextTick(cb.bind(null, {code: 'ENOENT'})) | ||
} | ||
else { | ||
} else { | ||
process.nextTick(cb.bind(null, null, '#define NODE_MODULE_VERSION 555')) | ||
@@ -86,2 +85,3 @@ } | ||
getAbi(opts, v, function (err, abi) { | ||
t.error(err, 'getAbi should not fail') | ||
t.equal(readCount, 3, 'read three times') | ||
@@ -88,0 +88,0 @@ t.equal(abi, '555', 'abi version after retry') |
@@ -15,3 +15,3 @@ var test = require('tape') | ||
test('downloading from GitHub, not cached', function (t) { | ||
t.plan(19) | ||
t.plan(20) | ||
rm.sync(build) | ||
@@ -23,2 +23,3 @@ rm.sync(util.prebuildCache()) | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch, path: __dirname}, | ||
@@ -30,4 +31,3 @@ log: { | ||
t.equal(message, 'GET ' + downloadUrl) | ||
} | ||
else { | ||
} else { | ||
t.equal(type, 200, 'status code logged') | ||
@@ -46,11 +46,27 @@ t.equal(message, downloadUrl) | ||
var cachedPrebuild = util.cachedPrebuild(downloadUrl) | ||
var npmCache = util.npmCache() | ||
var tempFile | ||
var existsCallNum = 0 | ||
var _access = fs.access ? fs.access.bind(fs) : fs.access | ||
var _exists = fs.exists.bind(fs) | ||
if (_access) { | ||
fs.access = function (path, a, cb) { | ||
if (existsCallNum++ === 0) { | ||
t.equal(path, npmCache, 'fs.exists called for npm cache') | ||
_access(path, cb) | ||
} | ||
} | ||
} | ||
fs.exists = function (path, cb) { | ||
t.equal(path, cachedPrebuild, 'fs.exists called') | ||
_exists(path, function (exists) { | ||
t.equal(exists, false, 'prebuild should not be cached') | ||
cb(exists) | ||
}) | ||
if (existsCallNum++ === 0) { | ||
t.equal(path, npmCache, 'fs.exists called for npm cache') | ||
_exists(path, cb) | ||
} else { | ||
t.equal(path, cachedPrebuild, 'fs.exists called for prebuild') | ||
_exists(path, function (exists) { | ||
t.equal(exists, false, 'prebuild should be cached') | ||
cb(exists) | ||
}) | ||
} | ||
} | ||
@@ -74,4 +90,3 @@ | ||
t.ok(/\.tmp$/i.test(path), 'this is the temporary file') | ||
} | ||
else { | ||
} else { | ||
t.ok(/\.node$/i.test(path), 'this is the unpacked file') | ||
@@ -104,2 +119,3 @@ } | ||
fs.exists = _exists | ||
fs.access = _access | ||
fs.mkdir = _mkdir | ||
@@ -112,3 +128,3 @@ fs.createWriteStream = _createWriteStream | ||
test('cached prebuild', function (t) { | ||
t.plan(9) | ||
t.plan(10) | ||
rm.sync(build) | ||
@@ -118,2 +134,3 @@ | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch, path: __dirname}, | ||
@@ -130,10 +147,26 @@ log: { | ||
var cachedPrebuild = util.cachedPrebuild(downloadUrl) | ||
var npmCache = util.npmCache() | ||
var existsCallNum = 0 | ||
var _access = fs.access ? fs.access.bind(fs) : fs.access | ||
var _exists = fs.exists.bind(fs) | ||
if (_access) { | ||
fs.access = function (path, a, cb) { | ||
if (existsCallNum++ === 0) { | ||
t.equal(path, npmCache, 'fs.exists called for npm cache') | ||
_access(path, cb) | ||
} | ||
} | ||
} | ||
fs.exists = function (path, cb) { | ||
t.equal(path, cachedPrebuild, 'fs.exists called') | ||
_exists(path, function (exists) { | ||
t.equal(exists, true, 'prebuild should be cached') | ||
cb(exists) | ||
}) | ||
if (existsCallNum++ === 0) { | ||
t.equal(path, npmCache, 'fs.exists called for npm cache') | ||
_exists(path, cb) | ||
} else { | ||
t.equal(path, cachedPrebuild, 'fs.exists called for prebuild') | ||
_exists(path, function (exists) { | ||
t.equal(exists, true, 'prebuild should be cached') | ||
cb(exists) | ||
}) | ||
} | ||
} | ||
@@ -161,2 +194,3 @@ | ||
fs.exists = _exists | ||
fs.access = _access | ||
}) | ||
@@ -170,2 +204,3 @@ }) | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch, path: __dirname}, | ||
@@ -177,5 +212,2 @@ updateName: function (entry) { | ||
var downloadUrl = util.getDownloadUrl(opts) | ||
var cachedPrebuild = util.cachedPrebuild(downloadUrl) | ||
download(opts, function (err) { | ||
@@ -192,2 +224,3 @@ t.equal(err.message, 'Missing .node file in archive', 'correct error message') | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch}, | ||
@@ -229,2 +262,3 @@ log: { | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch}, | ||
@@ -237,4 +271,3 @@ log: { | ||
t.equal(message, 'GET ' + downloadUrl) | ||
} | ||
else { | ||
} else { | ||
t.equal(type, 404, 'invalid resource') | ||
@@ -275,2 +308,3 @@ t.equal(message, downloadUrl) | ||
pkg: pkg, | ||
nolocal: true, | ||
rc: {platform: process.platform, arch: process.arch}, | ||
@@ -277,0 +311,0 @@ log: {http: function () { }} |
@@ -38,3 +38,4 @@ var test = require('tape') | ||
t.equal(path, tarPath, 'correct tar path') | ||
return resultStream = _createWriteStream(path) | ||
resultStream = _createWriteStream(path) | ||
return resultStream | ||
} | ||
@@ -41,0 +42,0 @@ |
var test = require('tape') | ||
var path = require('path') | ||
var rc = require('../rc') | ||
var exec = require('child_process').exec | ||
test('default config', function (t) { | ||
t.equal(rc.target, process.version, 'correct target') | ||
t.equal(rc.arch, process.arch, 'correct arch') | ||
t.equal(rc.platform, process.platform, 'correct platform') | ||
t.equal(rc.compile, false, 'compile is explicit') | ||
t.equal(rc.force, false, 'force is explicit') | ||
t.equal(rc.debug, false, 'debug not set') | ||
t.equal(rc.path, '.', 'correct path') | ||
t.equal(rc.help, undefined, 'help not set') | ||
t.equal(rc.download, undefined, 'download not set') | ||
t.equal(rc.version, undefined, 'version not set') | ||
t.equal(rc.preinstall, undefined, 'preinstall not set') | ||
t.end() | ||
}) | ||
test('custom config and aliases', function (t) { | ||
@@ -38,4 +22,2 @@ var args = [ | ||
runRc(t, args.join(' '), function (rc) { | ||
t.deepEqual(rc.target, [ 'vX.Y.Z', 'vZ.Y.X' ], 'correct targets') | ||
t.deepEqual(rc.target, rc.t) | ||
t.equal(rc.arch, 'ARCH', 'correct arch') | ||
@@ -74,4 +56,3 @@ t.equal(rc.arch, rc.a) | ||
t.pass('json parsed correctly') | ||
} | ||
catch (e) { | ||
} catch (e) { | ||
t.fail(e.message) | ||
@@ -78,0 +59,0 @@ } |
var test = require('tape') | ||
var ghreleases = require('ghreleases') | ||
var upload = require('../upload') | ||
@@ -49,4 +48,3 @@ var pkg = require('a-native-module/package') | ||
test('uploading to GitHub, only uploading not uploaded files', function (t) { | ||
var opts = basicSetup(t, [{name: 'foo.tar.gz' }, {name: 'baz.tar.gz' }]) | ||
var error = new Error('uploadAssets failed miserably, buu huu') | ||
var opts = basicSetup(t, [{name: 'foo.tar.gz'}, {name: 'baz.tar.gz'}]) | ||
opts.gh.uploadAssets = function (auth, user, repo, ref, filtered, cb) { | ||
@@ -57,3 +55,3 @@ process.nextTick(cb) | ||
t.deepEqual(result.new, ['bar.tar.gz'], 'files are filtered correctly') | ||
t.deepEqual(result.old, ['foo.tar.gz','baz.tar.gz'], 'files are filtered correctly') | ||
t.deepEqual(result.old, ['foo.tar.gz', 'baz.tar.gz'], 'files are filtered correctly') | ||
t.error(err, 'no error') | ||
@@ -75,3 +73,3 @@ t.end() | ||
t.equal(repo, 'a-native-module', 'correct repo') | ||
t.deepEqual(opts, {tag_name: 'v'+pkg.version}, 'correct opts') | ||
t.deepEqual(opts, {tag_name: 'v' + pkg.version}, 'correct opts') | ||
process.nextTick(cb) | ||
@@ -83,3 +81,3 @@ }, | ||
t.equal(repo, 'a-native-module', 'correct repo') | ||
t.equal(tag, 'v'+pkg.version, 'correct tag') | ||
t.equal(tag, 'v' + pkg.version, 'correct tag') | ||
process.nextTick(function () { cb(null, {assets: assets || []}) }) | ||
@@ -86,0 +84,0 @@ }, |
@@ -203,2 +203,3 @@ var test = require('tape') | ||
util.readGypFile(v, file, function (err, data) { | ||
t.error(err, 'readGypFile should succeed') | ||
fs.readFile = _readFile | ||
@@ -271,3 +272,3 @@ t.end() | ||
rc: { debug: true }, | ||
pkg: { binary: {module_path: 'foo/bar' }} | ||
pkg: { binary: { module_path: 'foo/bar' } } | ||
}), 'foo/bar', 'using binary property from package.json') | ||
@@ -274,0 +275,0 @@ t.end() |
@@ -12,5 +12,7 @@ var path = require('path') | ||
var url = github(pkg) | ||
if (!url) return process.nextTick(function () { | ||
cb(new Error('package.json is missing a repository field')) | ||
}) | ||
if (!url) { | ||
return process.nextTick(function () { | ||
cb(new Error('package.json is missing a repository field')) | ||
}) | ||
} | ||
@@ -42,5 +44,4 @@ var user = url.split('/')[3] | ||
}) | ||
} | ||
module.exports = upload |
20
util.js
@@ -29,3 +29,6 @@ var fs = require('fs') | ||
function urlTemplate (opts) { | ||
if (typeof opts.rc.download == 'string') return opts.rc.download | ||
if (typeof opts.rc.download === 'string') { | ||
return opts.rc.download | ||
} | ||
var packageName = '{name}-v{version}-node-v{abi}-{platform}-{arch}.tar.gz' | ||
@@ -52,5 +55,8 @@ if (opts.pkg.binary) { | ||
function npmCache () { | ||
return process.env.APPDATA ? path.join(process.env.APPDATA, 'npm-cache') : path.join(home(), '.npm') | ||
} | ||
function prebuildCache () { | ||
var npm = process.env.APPDATA ? path.join(process.env.APPDATA, 'npm-cache') : path.join(home(), '.npm') | ||
return path.join(npm, '_prebuilds') | ||
return path.join(npmCache(), '_prebuilds') | ||
} | ||
@@ -73,2 +79,6 @@ | ||
function localPrebuild (url) { | ||
return path.join('prebuilds', path.basename(url)) | ||
} | ||
function readGypFile (version, file, cb) { | ||
@@ -94,3 +104,3 @@ fs.exists(path.join(nodeGypPath(), 'iojs-' + version), function (isIojs) { | ||
args = args || [] | ||
if (typeof args == 'function') { | ||
if (typeof args === 'function') { | ||
cb = args | ||
@@ -118,3 +128,5 @@ args = [] | ||
exports.cachedPrebuild = cachedPrebuild | ||
exports.localPrebuild = localPrebuild | ||
exports.prebuildCache = prebuildCache | ||
exports.npmCache = npmCache | ||
exports.tempFile = tempFile | ||
@@ -121,0 +133,0 @@ exports.getTarPath = getTarPath |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances 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
63441
1687
4
23