node-pre-gyp
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -20,3 +20,4 @@ | ||
, commands = [ | ||
'rebuild' | ||
'rebuild', | ||
'publish' | ||
] | ||
@@ -23,0 +24,0 @@ , aliases = { |
@@ -17,3 +17,6 @@ | ||
, cp = require('child_process') | ||
, versioning = require('./util/versioning.js') | ||
, compile = require('./util/compile.js') | ||
function test_binary(opts,callback) { | ||
@@ -45,24 +48,2 @@ var args = []; | ||
function compile(args,callback) { | ||
var shell_cmd = 'node-gyp'; | ||
if (win) { | ||
shell_cmd = 'node-gyp.cmd'; | ||
} | ||
console.log(args); | ||
var cmd = cp.spawn(shell_cmd,args, {cwd: undefined, env: process.env, customFds: [ 0, 1, 2]}); | ||
cmd.on('error', function (err) { | ||
if (err) { | ||
return callback(new Error("Failed to execute '" + shell_cmd + ' ' + shell_args.join(' ') + "' (" + err + ")")); | ||
} | ||
callback(); | ||
}); | ||
cmd.on('close', function (err, stdout, stderr) { | ||
if (err) { | ||
return callback(new Error("Failed to execute '" + shell_cmd + ' ' + shell_args.join(' ') + "' (" + err + ")")); | ||
} | ||
callback(); | ||
}); | ||
} | ||
function download(url,opts,callback) { | ||
@@ -152,69 +133,18 @@ log.http('GET', url) | ||
function validate_config(package_json,callback) { | ||
if (!package_json.main) { | ||
return callback(new Error("package.json must declare 'main'")); | ||
} | ||
if (!package_json.binary) { | ||
return callback(new Error("package.json must declare 'binary' object'")); | ||
} | ||
var o = package_json.binary; | ||
if (!o.module_path) { | ||
return callback(new Error("package.json must declare 'binary.module_path'")); | ||
} | ||
if (!o.module_name) { | ||
return callback(new Error("package.json must declare 'binary.module_name'")); | ||
} | ||
if (!o.template) { | ||
return callback(new Error("package.json must declare 'binary.template'")); | ||
} | ||
if (!o.remote_uri) { | ||
return callback(new Error("package.json must declare 'binary.remote_uri'")); | ||
} | ||
callback(); | ||
}; | ||
function eval_template(template,opts) { | ||
Object.keys(opts).forEach(function(key) { | ||
template = template.replace('{'+key+'}',opts[key]); | ||
}); | ||
return template; | ||
} | ||
function get_node_abi() { | ||
// process.versions.modules added in >= v0.10.4 and v0.11.7 | ||
// https://github.com/joyent/node/commit/ccabd4a6fa8a6eb79d29bc3bbe9fe2b6531c2d8e | ||
return process.versions.modules ? 'node-v' + (+process.versions.modules) : | ||
'v8-' + process.versions.v8.split('.').slice(0,2).join('.'); | ||
} | ||
function rebuild(gyp, argv, callback) { | ||
// @TODO - respect -C/--directory | ||
var package_json = JSON.parse(fs.readFileSync('./package.json')); | ||
validate_config(package_json,function(err) { | ||
if (gyp.opts['build-from-source'] | ||
&& (gyp.opts['build-from-source'] === true | ||
|| gyp.opts['build-from-source'] === package_json.name)) { | ||
return compile.run_gyp(['rebuild'],callback); | ||
} | ||
versioning.evaluate(package_json, gyp.opts, function(err,opts) { | ||
if (err) return callback(err); | ||
if (gyp.opts['build-from-source'] | ||
&& (gyp.opts['build-from-source'] === true | ||
|| gyp.opts['build-from-source'] === package_json.name)) { | ||
return compile(['rebuild'],callback); | ||
} | ||
var module_version = semver.parse(package_json.version); | ||
var opts = { | ||
configuration: (gyp.opts.debug === true) ? 'Debug' : 'Release' | ||
, module_name: package_json.binary.module_name | ||
, major: module_version.major | ||
, minor: module_version.minor | ||
, patch: module_version.patch | ||
, node_abi: get_node_abi() | ||
, platform: process.platform | ||
, arch: process.arch | ||
, target_arch: gyp.opts.target_arch || process.arch | ||
, module_main: package_json.main | ||
} | ||
var versioned = eval_template(package_json.binary.template,opts); | ||
var from = package_json.binary.remote_uri + '/' + versioned; | ||
var from = package_json.binary.remote_uri + '/' + opts.versioned; | ||
var to = package_json.binary.module_path; | ||
var binary_module = path.join(to,opts.module_name); | ||
var binary_module = path.join(to,opts.module_name+'.node'); | ||
if (existsAsync(binary_module,function(found) { | ||
if (found) { | ||
log.verbose('install','already in place'); | ||
log.info('install','Sweet: "'+binary_module+'" is installed!'); | ||
callback(); | ||
@@ -225,6 +155,6 @@ } else { | ||
log.verbose('build','source compile required'); | ||
compile(['rebuild'],callback); | ||
compile.run_gyp(['rebuild'],callback); | ||
} else { | ||
test_binary(opts,function(err) { | ||
if (err) compile(['rebuild'],callback); | ||
if (err) compile.run_gyp(['rebuild'],callback); | ||
return callback(); | ||
@@ -231,0 +161,0 @@ }); |
{ | ||
"name": "node-pre-gyp", | ||
"description": "Node.js native addon binary install tool", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"keywords": [ | ||
@@ -27,3 +27,4 @@ "native", | ||
"semver": "~2.1", | ||
"tar": "0" | ||
"tar": "0", | ||
"tar-pack":"*" | ||
}, | ||
@@ -30,0 +31,0 @@ "engines": { |
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
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
25547
14
663
6
1
18
7
+ Addedtar-pack@*
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedfstream@1.0.12(transitive)
+ Addedfstream-ignore@1.0.5(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtar@2.2.2(transitive)
+ Addedtar-pack@3.4.1(transitive)
+ Addeduid-number@0.0.6(transitive)
+ Addedutil-deprecate@1.0.2(transitive)