diff --git a/rc.js b/rc.js index 496ea09..16fd1e7 100644 --- a/rc.js +++ b/rc.js @@ -29,6 +29,8 @@ if (env.npm_config_argv) { // Get the configuration module.exports = function (pkg) { var pkgConf = pkg.config || {} + var sourceBuild = env.npm_config_build_from_source + var buildFromSource = sourceBuild === pkg.name || sourceBuild === 'true' var rc = require('rc')('prebuild-install', { target: pkgConf.target || env.npm_config_target || process.versions.node, runtime: pkgConf.runtime || env.npm_config_runtime || 'node', @@ -39,7 +41,7 @@ module.exports = function (pkg) { force: false, verbose: false, prebuild: true, - compile: false, + compile: buildFromSource, path: '.', proxy: env.npm_config_proxy || env['HTTP_PROXY'], 'https-proxy': env.npm_config_https_proxy || env['HTTPS_PROXY'], diff --git a/test/rc-test.js b/test/rc-test.js index 4de54fe..4a46eed 100644 --- a/test/rc-test.js +++ b/test/rc-test.js @@ -68,7 +68,8 @@ test('npm_config_* are passed on from environment into rc', function (t) { npm_config_local_address: 'LOCAL_ADDRESS', npm_config_target: '1.4.0', npm_config_runtime: 'electron', - npm_config_platform: 'PLATFORM' + npm_config_platform: 'PLATFORM', + npm_config_build_from_source: 'true' } runRc(t, '', env, function (rc) { t.equal(rc.proxy, 'PROXY', 'proxy is set') @@ -77,6 +78,7 @@ test('npm_config_* are passed on from environment into rc', function (t) { t.equal(rc.target, '1.4.0', 'target is set') t.equal(rc.runtime, 'electron', 'runtime is set') t.equal(rc.platform, 'PLATFORM', 'platform is set') + t.equal(rc.compile, true, 'build-from-source is set') t.end() }) })