diff --git a/.github/workflows/CI.ps1 b/.github/workflows/CI.ps1 new file mode 100644 index 0000000..47ed214 --- /dev/null +++ b/.github/workflows/CI.ps1 @@ -0,0 +1,20 @@ +. $PSScriptRoot/../../esh/main.ps1 + +try{ + $EshellUI.Init($MyInvocation) + $EshellUI.Start() +} +catch{ + $error | ForEach-Object { + Write-Output "::error file=$($_.InvocationInfo.ScriptName),line=$($_.InvocationInfo.ScriptLineNumber),col=$($_.InvocationInfo.OffsetInLine),endColumn=$($_.InvocationInfo.OffsetInLine),tittle=error::script error" + Write-Output "::group::script stack trace" + Write-Output $_.ScriptStackTrace + Write-Output "::endgroup::" + Write-Output "::group::error details" + Write-Output $_ + Write-Output "::endgroup::" + } + exit 1 +} + +Write-Output "Nice CI!" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..bfad957 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,15 @@ +name: CI + +on: + push: + pull_request: + branches: [ "master" ] + workflow_dispatch: + +jobs: + test: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Run a one-line script + run: pwsh ./.github/workflows/CI.ps1 diff --git a/esh/src/commands/esh_base.ps1 b/esh/src/commands/esh_base.ps1 index 40ab09b..84c4925 100644 --- a/esh/src/commands/esh_base.ps1 +++ b/esh/src/commands/esh_base.ps1 @@ -64,8 +64,8 @@ function global:sudo { $ShadowHandled=($Shadow.ToCharArray() | ForEach-Object { if($Width -eq 0) { $Width = [Math]::Max([Math]::Floor( - [System.Windows.Forms.TextRenderer]::MeasureText($_, $Font).Width - /128)-1,0) + [System.Windows.Forms.TextRenderer]::MeasureText($_, $Font).Width/ + 128)-1,0) } elseif($_ -eq $LastChar) { $Width--;return } else{ $UseOriginal = $true } diff --git a/esh/src/main.ps1 b/esh/src/main.ps1 index 2da6d19..d4aea58 100644 --- a/esh/src/main.ps1 +++ b/esh/src/main.ps1 @@ -11,7 +11,8 @@ $EshellUI = ValueEx @{ } Im = @{ Sudo = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]“Administrator”) - VSCodeExtension = [bool]($psEditor) + VSCodeExtension = [bool]($psEditor) -and ($Host.Name -eq 'Visual Studio Code Host') + Editor = [bool]($psEditor) WindowsPowerShell = (Split-Path $(Split-Path $PROFILE) -Leaf) -eq 'WindowsPowerShell' ISE = [bool]($psISE) FirstLoading = $EshellUI -eq $LastExitCode