From ea86df4875496fb4528046980b164c4602d679d1 Mon Sep 17 00:00:00 2001 From: Brantone Date: Wed, 8 Jun 2022 17:04:41 -0700 Subject: [PATCH] To ensure consistent environment between 'npm install' and 'npm list', pass same environment variables --- CHANGELOG.md | 2 ++ libraries/nodejs_helper.rb | 4 +--- resources/npm_package.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d078d99..0f712992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- To ensure consistent environment between `npm install` and `npm list`, pass same environment variables. + ## 10.0.0 - *2022-04-21* - Update to NodeJS 17.x diff --git a/libraries/nodejs_helper.rb b/libraries/nodejs_helper.rb index f6f46c71..59418225 100644 --- a/libraries/nodejs_helper.rb +++ b/libraries/nodejs_helper.rb @@ -47,9 +47,7 @@ def version_valid?(list, package, version) (version ? list[package]['version'] == version : true) end - def npm_package_installed?(package, version = nil, path = nil, npm_token = nil) - environment = { 'NPM_TOKEN' => npm_token } if npm_token - + def npm_package_installed?(package, version = nil, path = nil, environment = {}) list = npm_list(package, path, environment)['dependencies'] # Return true if package installed and installed to good version # see if we really want to add the url check diff --git a/resources/npm_package.rb b/resources/npm_package.rb index ac1a85f0..d33de97a 100644 --- a/resources/npm_package.rb +++ b/resources/npm_package.rb @@ -82,7 +82,7 @@ def npm_env_vars end def package_installed? - new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, new_resource.npm_token) + new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, npm_env_vars) end def no_auto_update?