Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cross-installing of prebuilt packages via npm_config_* vars #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ var proc = require('child_process')
var os = require('os')
var path = require('path')

var targetMismatch = (process.env.npm_config_platform && process.platform !== process.env.npm_config_platform) ||
vweevers marked this conversation as resolved.
Show resolved Hide resolved
(process.env.npm_config_arch && process.arch !== process.env.npm_config_arch)
vweevers marked this conversation as resolved.
Show resolved Hide resolved

if (!buildFromSource()) {
proc.exec('node-gyp-build-test', function (err, stdout, stderr) {
if (err) {
if (verbose()) console.error(stderr)
preinstall()
}
})
if (targetMismatch) {
// If the target is mismatched, then we can't test built output, and we can't build from source either.
pimterry marked this conversation as resolved.
Show resolved Hide resolved
// Instead, we just check whether a matching prebuild exists, and fail if it doesn't.
require('./index').path(process.cwd())
pimterry marked this conversation as resolved.
Show resolved Hide resolved
} else {
proc.exec('node-gyp-build-test', function (err, stdout, stderr) {
vweevers marked this conversation as resolved.
Show resolved Hide resolved
if (err) {
if (verbose()) console.error(stderr)
preinstall()
}
})
}
} else {
preinstall()
}
Expand Down