Add a script for running bash
from powershell
This commit is contained in:
parent
654370f4f0
commit
ea1078e5db
2 changed files with 18 additions and 14 deletions
14
scripts/Windows/Scripts/BashScript.ps1
Normal file
14
scripts/Windows/Scripts/BashScript.ps1
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -1,25 +1,15 @@
|
||||||
#!/bin/pwsh
|
#!/bin/pwsh
|
||||||
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/BashScript.ps1";
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
function Backup-Git([Context] $context) {}
|
function Backup-Git([Context] $context) {}
|
||||||
|
|
||||||
function Restore-Git([Context] $context) {
|
function Restore-Git([Context] $context) {
|
||||||
Write-Host "Restoring git";
|
Write-Host "Restoring git";
|
||||||
$script = New-TemporaryFile;
|
|
||||||
$script = Rename-Item $script "$($script.Name).sh" -PassThru;
|
|
||||||
|
|
||||||
Write-Information "Preparing setup script";
|
Start-BashScript @(
|
||||||
|
"bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"",
|
||||||
Set-Content $script (
|
"rm ~/.bashrc");
|
||||||
[string]::Join(
|
|
||||||
"`n",
|
|
||||||
@(
|
|
||||||
"bash `"$PSScriptRoot/../../../Common/Config/git/install.sh`"",
|
|
||||||
"rm ~/.bashrc")));
|
|
||||||
|
|
||||||
Write-Information "Running prepared script";
|
|
||||||
Start-Process -Wait $script;
|
|
||||||
Remove-Item $script;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue