fix: Make hook shell optional with OS-based defaults (#3613)#5809
Conversation
- Auto-detect shell based on OS when not explicitly specified (pwsh for Windows, sh for others) - Display warnings to inform users about default shell usage and encourage explicit configuration - Add comprehensive validation and warning system in both middleware and hooks run command - Update tests to reflect new behavior where missing shell is no longer an error - Maintain backward compatibility for existing hook configurations Fixes Azure#3613
|
This is fantastic, @vhvb1989 -- thank you! What do you think about adding a short aka link to the error message? aka.ms/azd-hooks |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
Thanks, this will simplify many of our config files! |
Reflects Azure/azure-dev#5809: shell is now optional. When omitted, azd uses pwsh on Windows and sh on Linux/macOS and prints a warning recommending an explicit value.
Overview
This PR addresses issue #3613 by making the shell configuration optional for hooks and implementing automatic OS-based shell detection.
Changes Made
Core Functionality
pwshon Windows andshon Linux/macOSKey Files Modified
pkg/ext/models.go: Added OS-based shell detection and default shell trackingpkg/ext/hooks_manager.go: Enhanced validation to detect and warn about default shell usagecmd/hooks.go: Added validation and warning display toazd hooks runcommandWarning Examples
Before (Error):
After (Working with Warning):
Example Usage
Testing
azd hooks runcommandFixes
Closes #3613
Type of Change