From c8abfb43cb57905ed639ff90e9353d0325171587 Mon Sep 17 00:00:00 2001 From: Adrian Pascu <1521321+adipascu@users.noreply.github.com> Date: Fri, 5 Apr 2019 12:09:09 +0300 Subject: [PATCH 1/5] Add support for the build_from_source npm config Implements #98 --- rc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.js b/rc.js index 496ea09..994d77d 100644 --- a/rc.js +++ b/rc.js @@ -39,7 +39,7 @@ module.exports = function (pkg) { force: false, verbose: false, prebuild: true, - compile: false, + compile: env.npm_config_build_from_source === 'true', path: '.', proxy: env.npm_config_proxy || env['HTTP_PROXY'], 'https-proxy': env.npm_config_https_proxy || env['HTTPS_PROXY'], From 23bcf29a3c792fb7f6f5ef587c2dcca790e35a63 Mon Sep 17 00:00:00 2001 From: Adi Pascu Date: Fri, 5 Apr 2019 12:18:01 +0300 Subject: [PATCH 2/5] Improve node-pre-gyp compatibility --- rc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rc.js b/rc.js index 994d77d..05050ab 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 source_build = env.npm_config_build_from_source; + var buildFromSource = source_build === pkg.name || (source_build === true || source_build === '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: env.npm_config_build_from_source === 'true', + compile: buildFromSource, path: '.', proxy: env.npm_config_proxy || env['HTTP_PROXY'], 'https-proxy': env.npm_config_https_proxy || env['HTTPS_PROXY'], From a1febdbe039e1a1849690a3e7fdf1f82888b2e2b Mon Sep 17 00:00:00 2001 From: Adi Pascu Date: Fri, 5 Apr 2019 12:48:04 +0300 Subject: [PATCH 3/5] Fix lint warnings --- rc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc.js b/rc.js index 05050ab..1ba5a14 100644 --- a/rc.js +++ b/rc.js @@ -29,8 +29,8 @@ if (env.npm_config_argv) { // Get the configuration module.exports = function (pkg) { var pkgConf = pkg.config || {} - var source_build = env.npm_config_build_from_source; - var buildFromSource = source_build === pkg.name || (source_build === true || source_build === 'true'); + var sourceBuild = env.npm_config_build_from_source + var buildFromSource = sourceBuild === pkg.name || (sourceBuild === true || 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', From ba21172cc97d5922f53a2371ad409de7a6445105 Mon Sep 17 00:00:00 2001 From: Adi Pascu Date: Fri, 5 Apr 2019 13:23:42 +0300 Subject: [PATCH 4/5] Update unit tests --- test/rc-test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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() }) }) From 5284ef35c1adfd181a05f38e80101396c1cbd7e2 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 5 Apr 2019 17:41:17 +0300 Subject: [PATCH 5/5] Update rc.js Co-Authored-By: adipascu <1521321+adipascu@users.noreply.github.com> --- rc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.js b/rc.js index 1ba5a14..16fd1e7 100644 --- a/rc.js +++ b/rc.js @@ -30,7 +30,7 @@ if (env.npm_config_argv) { module.exports = function (pkg) { var pkgConf = pkg.config || {} var sourceBuild = env.npm_config_build_from_source - var buildFromSource = sourceBuild === pkg.name || (sourceBuild === true || sourceBuild === 'true') + 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',