diff --git a/scripts/Windows/Scripts/BashScript.ps1 b/scripts/Windows/Scripts/BashScript.ps1 new file mode 100644 index 00000000..3b80bad3 --- /dev/null +++ b/scripts/Windows/Scripts/BashScript.ps1 @@ -0,0 +1,14 @@ +function Start-BashScript() { + param( + [Parameter(Mandatory=$true, Position=0)] + [string[]]$Content + ) + + Write-Information "Preparing setup script"; + $script = New-TemporaryFile; + $script = Rename-Item $script -NewName "$script.sh" -PassThru; + Set-Content $script ([string]::Join("`n", $Content)); + Write-Information "Running prepared script"; + Start-Process -Wait $script; + Remove-Item $script; +} diff --git a/scripts/Windows/Software/git/Manage.ps1 b/scripts/Windows/Software/git/Manage.ps1 index aad63ee8..a89c0c10 100644 --- a/scripts/Windows/Software/git/Manage.ps1 +++ b/scripts/Windows/Software/git/Manage.ps1 @@ -1,25 +1,15 @@ #!/bin/pwsh . "$PSScriptRoot/../../Scripts/Context.ps1"; +. "$PSScriptRoot/../../Scripts/BashScript.ps1"; $null = New-Module { function Backup-Git([Context] $context) {} function Restore-Git([Context] $context) { Write-Host "Restoring git"; - $script = New-TemporaryFile; - $script = Rename-Item $script "$($script.Name).sh" -PassThru; - Write-Information "Preparing setup script"; - - Set-Content $script ( - [string]::Join( - "`n", - @( - "bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"", - "rm ~/.bashrc"))); - - Write-Information "Running prepared script"; - Start-Process -Wait $script; - Remove-Item $script; + Start-BashScript @( + "bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"", + "rm ~/.bashrc"); } }