-
Notifications
You must be signed in to change notification settings - Fork 45
fix: Expand tilde for chdir (issue #389) #390
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to make it work across all operating systems.
@@ -23,6 +23,11 @@ function Invoke-Terraform { | |||
[switch] $silent | |||
) | |||
|
|||
# Avoid bootstrap Terraform chdir errors if ~ in moduleFolderPath | |||
if ($env:HOME -and $env:HOME -ne "" -and $moduleFolderPath -match '^(~)') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this work for Windows too?
E.g.
$homeDirectoryPath = $env:HOME
if($IsWindows) {
$homeDirectoryPath = $env:HOMEPATH
}
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, you can just use $HOME
for a cross platform solution in PowerShell Core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, just use Resolve-Path $moduleFolderPath
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So change to (Resolve-Path ~/accelerator/output).Path
?
This gives a consistent result (that should work for chdir) for
- absolute path
- relative path
- path including tilde
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested a re-bootstrap and then rerun CI & CD workflows successfully, again in pwsh on Ubuntu on Win 11 ARM WSL.
Pull Request
Issue
Fixes #389
Description
Expands ~ with $env:HOME if found in moduleFolderPath
License
By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.