Skip to content

Commit

Permalink
Update code detection logic.
Browse files Browse the repository at this point in the history
Now if -WithInsiders is specified, looks for code-insiders first. Also looks for insiders after looking for code by default so if you don't have stable installed, you can still use the function
  • Loading branch information
corbob committed Oct 17, 2019
1 parent b880867 commit 431d36b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions PSProfile/Public/Power Tools/Open-Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ function Open-Code {
}
}
Process {
$codeCommand = @('code','code-insiders')
if($WithInsiders) {
$code = (Get-Command code-insiders -All | Where-Object { $_.CommandType -notin @('Function','Alias') })[0].Source
}
if($null -eq $code){
$code = (Get-Command code -All | Where-Object { $_.CommandType -notin @('Function','Alias') })[0].Source
$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 431d36b

Please sign in to comment.