Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Fix plugin install error not displayed correctly #955

Merged
merged 4 commits into from Mar 20, 2023

Conversation

t1m0thyj
Copy link
Member

@t1m0thyj t1m0thyj commented Mar 13, 2023

Fixes #954 by adding utility method ProcessUtils.execAndCheckOutput that wraps child_process.spawnSync for better error handling.

Notes:

  • Renamed methods in NpmFunctions.ts and removed an unused one - not a breaking change since this module is not exported
  • The reason for using http://localhost:4873/ as npm registry in some tests is that's the default port used by Verdaccio 🙂

Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.11 🎉

Comparison is base (df36dce) 89.39% compared to head (cd0bc88) 89.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #955      +/-   ##
==========================================
+ Coverage   89.39%   89.51%   +0.11%     
==========================================
  Files         207      207              
  Lines       11264    11259       -5     
  Branches     2506     2507       +1     
==========================================
+ Hits        10070    10078       +8     
+ Misses       1194     1181      -13     
Impacted Files Coverage Δ
...s/imperative/src/config/cmd/report-env/EnvQuery.ts 96.09% <100.00%> (ø)
...s/imperative/src/plugins/utilities/NpmFunctions.ts 100.00% <100.00%> (+37.50%) ⬆️
...e/src/plugins/utilities/npm-interface/uninstall.ts 94.11% <100.00%> (-0.17%) ⬇️
...erative/src/plugins/utilities/runValidatePlugin.ts 100.00% <100.00%> (ø)
packages/utilities/src/ProcessUtils.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@t1m0thyj t1m0thyj added the needs-ported Indicates that a PR needs to be ported (master - zowe-v1-lts) label Mar 15, 2023
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@t1m0thyj t1m0thyj marked this pull request as ready for review March 15, 2023 14:22
Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM!

Will approve once we determine if removing getNpmPath is ok 😋

if (result.stderr?.length > 0) {
msg += `\n${result.stderr.toString()}`;
}
throw new Error(msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw an ImperativeError?

There may be other places where we throw non Imperative errors. For example:

  • throw new Error("Failed to uninstall plugin, install folder still exists:\n " + installFolder);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is intended to be low-level and mimic the error handling behavior of child_process.execSync. If we throw an Imperative error that wraps the original error, it may affect how the original error gets logged. I'm open to switching if we think that using vanilla JS errors is bad practice here 🙂

@zFernand0 zFernand0 self-requested a review March 15, 2023 14:49
@sonarcloud
Copy link

sonarcloud bot commented Mar 15, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@zFernand0 zFernand0 merged commit c54a4b9 into master Mar 20, 2023
@zFernand0 zFernand0 deleted the fix/plugin-install-error branch March 20, 2023 18:09
@zFernand0 zFernand0 added the release-patch Indicates a patch to existing code has been applied label Mar 20, 2023
@zFernand0 zFernand0 restored the fix/plugin-install-error branch March 20, 2023 18:10
@zFernand0 zFernand0 deleted the fix/plugin-install-error branch March 20, 2023 18:10
@github-actions
Copy link

Release succeeded for the master branch. 🎉

The following packages have been published:

  • npm: @zowe/imperative@5.9.2

Powered by Octorelease 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-ported Indicates that a PR needs to be ported (master - zowe-v1-lts) release-patch Indicates a patch to existing code has been applied released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin install error not displayed correctly
4 participants