diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e849b1c..4e234056 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.1 - *2022-08-07* - Standardise files with files in sous-chefs/repo-management 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?