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

node-pre-gyp

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pre-gyp - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

lib/publish.js

3

lib/node-pre-gyp.js

@@ -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": {

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