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

Return all variables with matching prefix #137

Open
fourpastmidnight opened this issue May 9, 2023 · 0 comments
Open

Return all variables with matching prefix #137

fourpastmidnight opened this issue May 9, 2023 · 0 comments

Comments

@fourpastmidnight
Copy link
Contributor

So, I was wondering, what if there happened to be an environment variable already named <PREFIX><Buildvar>, e.g., BHBuildSystem? What would happen? would BuildHelpers overwrite it? None of the function documentation mentioned what would happen, and I couldn't overtly see that anything would be overwritten--in fact, it looked like a check was made. But, still, what would happen? So I ran a test:

PS C:\> ${ENV:BUILD_BuildSystem} = 'Local'
PS C:\> Set-BuildEnvironment -VariableNamePrefix 'BUILD_' -BuildOutput ./out -PassThru

Name                          Value
----                          -----
BUILD_ProjectPath             C:\MyProject\src\MyProject
BUILD_BranchName              build-enhancements
BUILD_CommitMessage           build: Update build script
BUILD_CommitHash              123abc...
BUILD_BuildNumber             0
BUILD_ProjectName             MyProject
BUILD_PSModuleManifest        C:\MyProject\src\MyProject.psd1
BUILD_ModulePath              C:\MyProject\src
BUILD_BuildOutput             C:\MyProject\src\MyProject\out

What happened to the BUILD_BuildSystem variable? It wasn't emitted. Why not? It's still there, of course:

PS C:\> Get-Item $ENV:\BUILD_BuildSystem
Local

It would be better if BuildHelpers returned all environment variables that it would set, even if BuildHelpers did not itself actually set the variable, e.g., if a variable that BuildHelpers would normally set already has a value in the environment, simply return that variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant