Skip to content

Commit

Permalink
Merge pull request #24 from corbob/issue22
Browse files Browse the repository at this point in the history
Add WithInsiders switch.
  • Loading branch information
scrthq authored Oct 17, 2019
2 parents 0532a48 + 431d36b commit 8f7272b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion PSProfile/Public/Power Tools/Open-Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function Open-Code {
.PARAMETER Wait
If $true, waits for the file to be closed in Code before returning to the prompt. If $false, opens the file using a background job to allow immediately returning to the prompt. Defaults to $false.
.PARAMETER WithInsiders
If $true, looks for VS Code Insiders to load. If $true and code-insiders cannot be found, opens the file using VS Code stable. If $false, opens the file using VS Code stable. Defaults to $false.
.PARAMETER ArgumentList
Any additional arguments to be passed directly to the Code CLI command, e.g. `Open-Code --list-extensions` or `code --list-extensions` will still work the same as expected.
Expand Down Expand Up @@ -61,6 +64,10 @@ function Open-Code {
[Alias('w')]
[Switch]
$Wait,
[Alias('wi')]
[Alias('insiders')]
[Switch]
$WithInsiders,
[parameter(ValueFromRemainingArguments)]
[String[]]
$ArgumentList
Expand Down Expand Up @@ -111,7 +118,11 @@ function Open-Code {
}
}
Process {
$code = (Get-Command code -All | Where-Object { $_.CommandType -notin @('Function','Alias') })[0].Source
$codeCommand = @('code','code-insiders')
if($WithInsiders) {
$codeCommand = @('code-insiders','code')
}
$code = (Get-Command $codeCommand -All | Where-Object { $_.CommandType -notin @('Function','Alias') })[0].Source
if ($PSCmdlet.ParameterSetName -eq 'InputObject') {
$collection.Add($InputObject)
if ($PSBoundParameters.ContainsKey('Path')) {
Expand Down

0 comments on commit 8f7272b

Please sign in to comment.