Create $PROFILE's parent dir if it doesn't exists

This commit is contained in:
lksz 2020-10-02 15:54:23 -04:00
parent 90e1723052
commit e86c7350be
1 changed files with 5 additions and 1 deletions

View File

@ -169,7 +169,11 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { .
Invoke-ExpressionEx -sudo:$shouldSudo chmod 'a+r' $tmpOutput.FullName
}
try {
$local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo "Copy-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null; Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction Stop" 2>&1)
$local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo @"
if( -not (Test-Path $(Split-Path -Parent $p)) ) { New-Item -Type Directory $(Split-Path -Parent $p) -Force };
Copy-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null;
Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction Stop
"@ 2>&1)
if ( $errMsg ) {
Write-Error "$errMsg"
$status = $status -replace 'Need ', 'Failed '