Keep failed update output parseable for JSON and CSV#529
Conversation
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR fixes malformed machine-readable output when wp plugin update fails under --format=json or --format=csv, ensuring scripts can reliably parse the output while still signaling failure via exit code 1.
Changes:
- Exit early with status
1for failed updates in JSON/CSV mode to preventreport_batch_operation_results()from emitting an error message after structured output. - Add Behat regression coverage for failed plugin update output in JSON and CSV formats.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/WP_CLI/CommandWithUpgrade.php |
Halts with exit code 1 on update failures when using JSON/CSV output to keep structured output parseable. |
features/plugin-update.feature |
Adds regression scenarios asserting JSON/CSV output remains parseable on failed plugin updates and exit code is 1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fixes #161.
This fixes the output for failed plugin updates when using
--format=jsonor--format=csv.Before this change, the command could print structured output first and then append an error message after it. That made the JSON or CSV output hard to parse in scripts.
Changes
1for failed updates.Testing
composer lintcomposer phpcscomposer phpstangit diff --checkcomposer behat features/plugin-update.feature -- --name 'Failed plugin update keeps JSON output parseable'composer behat features/plugin-update.feature -- --name 'Failed plugin update keeps CSV output parseable'composer behat features/plugin-update.feature -- --name 'Skip plugin update when plugin directory is a VCS checkout'