prebuildify
Advanced tools
Comparing version 1.0.2 to 2.0.0
59
index.js
@@ -20,4 +20,7 @@ #!/usr/bin/env node | ||
var cwd = argv._[0] || '.' | ||
var builds = path.join(cwd, 'prebuilds') | ||
var builds = path.join(cwd, 'prebuilds', platform + '-' + arch) | ||
var output = path.join(cwd, 'build', argv.debug ? 'Debug' : 'Release') | ||
if (arch) process.env.ARCH = process.env.PREBUILD_ARCH = arch | ||
var targets = [].concat(argv.target || []).map(function (v) { | ||
@@ -56,13 +59,39 @@ if (v.indexOf('@') === -1) v = 'node@' + v | ||
build(next.target, next.runtime, function (err, filename) { | ||
copySharedLibs(output, builds, function (err) { | ||
if (err) return loop(err) | ||
var a = abi.getAbi(next.target, next.runtime) | ||
var name = platform + '-' + arch + '-' + next.runtime + '-' + a + '.node' | ||
var dest = path.join(builds, name) | ||
build(next.target, next.runtime, function (err, filename) { | ||
if (err) return loop(err) | ||
fs.rename(filename, dest, loop) | ||
var name = next.runtime + '-' + abi.getAbi(next.target, next.runtime) + '.node' | ||
var dest = path.join(builds, name) | ||
fs.rename(filename, dest, loop) | ||
}) | ||
}) | ||
} | ||
function copySharedLibs (builds, folder, cb) { | ||
fs.readdir(builds, function (err, files) { | ||
if (err) return cb(err) | ||
var libs = files.filter(function (name) { | ||
return /\.dylib$/.test(name) || /\.so(\.\d+)?$/.test(name) || /\.dll$/.test(name) | ||
}) | ||
loop() | ||
function loop (err) { | ||
if (err) return cb(err) | ||
var next = libs.shift() | ||
if (!next) return cb() | ||
strip(path.join(builds, next), function (err) { | ||
if (err) return cb(err) | ||
copy(path.join(builds, next), path.join(folder, next), loop) | ||
}) | ||
} | ||
}) | ||
} | ||
function preinstall (cb) { | ||
@@ -99,4 +128,2 @@ if (!argv.preinstall) return cb() | ||
var output = path.join(cwd, 'build', argv.debug ? 'Debug' : 'Release') | ||
var child = proc.spawn(os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', args, { | ||
@@ -112,3 +139,2 @@ cwd: cwd, | ||
if (err) return cb(err) | ||
if (!argv.strip) return cb(null, output) | ||
@@ -137,3 +163,3 @@ strip(output, function (err) { | ||
function strip (file, cb) { | ||
if (platform !== 'darwin' && platform !== 'linux') return process.nextTick(cb) | ||
if (!argv.strip || platform !== 'darwin' && platform !== 'linux') return process.nextTick(cb) | ||
@@ -152,1 +178,14 @@ var args = platform === 'darwin' ? [file, '-Sx'] : [file, '--strip-all'] | ||
} | ||
function copy (a, b, cb) { | ||
fs.stat(a, function (err, st) { | ||
if (err) return cb(err) | ||
fs.readFile(a, function (err, buf) { | ||
if (err) return cb(err) | ||
fs.writeFile(b, buf, function (err) { | ||
if (err) return cb(err) | ||
fs.chmod(b, st.mode, cb) | ||
}) | ||
}) | ||
}) | ||
} |
{ | ||
"name": "prebuildify", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Create and package prebuilds for native modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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 2 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
8079
146
3