Browse Source

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

master
lksz 1 year ago
parent
commit
e86c7350be
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      Setup-Profile.ps1

+ 5
- 1
Setup-Profile.ps1 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 '


Loading…
Cancel
Save