Fixed the salt.modules.npm module to check the npm version correctly on the Windows platform #51813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
On the Windows platform, the
salt.modules.npm
module does not check the npm version correctly. This is likely because thenpm
script that is installed is actuallynpm.CMD
. When checking the version, thesalt.modules.npm
module attempts to call justnpm
.This PR locates
npm
by usingsalt.utils.path.which()
to detect the path before checking the version. The version check usessalt.modules.cmdmod.run
whereas the rest of the module usessalt.modules.cmdmod.run_all
. It was not determined whysalt.modules.cmdmod.run
acts different fromsalt.modules.cmdmod.run_all
when running a cmd-script on the Windows platform.What issues does this PR fix or reference?
This closes issue #51811.
Previous Behavior
When performing the version check, the module is unable to locate the npm binary (or script, really) and thus the version check fails.
New Behavior
Due to checking for the full path of
npm.cmd
, the version is correctly detected and the rest of the module works. (npm.install
,npm.uninstall
, andnpm.list
was checked).Tests written?
No
Commits signed with GPG?
No