-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjvman.ps1
41 lines (30 loc) · 1.01 KB
/
jvman.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
if ($env:JVS_LEVEL -eq "DEBUG")
{
$executePath = $PSScriptRoot + "/target/debug/jvmain.exe"
} else {
$executePath = $PSScriptRoot + "/jvmain.exe"
}
$formatted_args = New-Object System.Collections.ArrayList
for($i=0; $i -le $args.Count; $i++){
if ($args[$i]){
$__ = $formatted_args.Add("`"" + $args[$i] +"`"" );
}
}
$env:JVS_EXEC_SHELL="pwsh"
$env:JVS_POSTSCRIPT = Join-Path $PSScriptRoot ("jvs_tmp_" + (Get-Random -SetSeed $PID) + ".ps1")
$startInfo = New-Object System.Diagnostics.ProcessStartInfo "`"$executePath`""
$startInfo.Arguments = ($formatted_args)
$startInfo.UseShellExecute = $false
$startInfo.RedirectStandardOutput = $true
$proc = [System.Diagnostics.Process]::Start($startInfo)
while (($b = $proc.StandardOutput.Read()) -ne -1) {
Write-Host -NoNewline ([char]$b)
}
$proc.WaitForExit
$exitCode = $proc.ExitCode
if ($env:JVS_POSTSCRIPT -and (Test-Path $env:JVS_POSTSCRIPT)) {
. $env:JVS_POSTSCRIPT
Remove-Item -Force $env:JVS_POSTSCRIPT
}
$env:JVS_POSTSCRIPT = $null
exit $exitCode