From 4366daaf65de6686013c75da474eac5c062ca800 Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 5 May 2020 16:57:41 -0600 Subject: Use environment variable instead of changing global configuration --- lib/license/finder/ext/npm.rb | 8 +++++++- lib/license/management/shell.rb | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/license/finder/ext/npm.rb b/lib/license/finder/ext/npm.rb index 75c0855..48741f9 100644 --- a/lib/license/finder/ext/npm.rb +++ b/lib/license/finder/ext/npm.rb @@ -16,7 +16,7 @@ module LicenseFinder def prepare Dir.chdir(project_path) do - shell.execute("#{prepare_command} --production") + shell.execute("#{prepare_command} --production", env: default_env) end end @@ -32,5 +32,11 @@ module LicenseFinder end status.success? ? JSON.parse(stdout) : {} end + + def default_env + return {} unless shell.custom_certificate_installed? + + { 'NPM_CONFIG_CAFILE' => ENV.fetch('NPM_CONFIG_CAFILE', shell.custom_certificate_path.to_s) } + end end end diff --git a/lib/license/management/shell.rb b/lib/license/management/shell.rb index fcf8188..7baa6ba 100644 --- a/lib/license/management/shell.rb +++ b/lib/license/management/shell.rb @@ -44,7 +44,6 @@ module License Dir.chdir custom_certificate_path.dirname do execute([:awk, SPLIT_SCRIPT, '<', custom_certificate_path]) execute('update-ca-certificates -v') - execute([:npm, :config, :set, :cafile, custom_certificate_path]) Dir.glob('custom.*.crt').each do |path| full_path = File.expand_path(path) -- cgit v1.2.3