Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure consistent environment between 'npm install' and 'npm list' #248

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions libraries/nodejs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion resources/npm_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down