Skip to content

Commit

Permalink
(chocolatey#3218) Update Tab Expansion to use Test-Path
Browse files Browse the repository at this point in the history
The method we were using to clear the error variable wasn't clearing the variable. Instead of trying this way, it's better to use Test-Path to verify if a file exists.
  • Loading branch information
corbob committed Jun 20, 2023
1 parent 24aa224 commit fe3151f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2017 - 2021 Chocolatey Software, Inc.
# Copyright © 2017 - 2021 Chocolatey Software, Inc.
# Copyright © 2011 - 2017 RealDimensions Software, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -62,9 +62,9 @@ $commandOptions = @{

$commandOptions['find'] = $commandOptions['search']

$licenseFile = Get-Item -Path "$env:ChocolateyInstall\license\chocolatey.license.xml" -ErrorAction Stop
$licenseFile = "$env:ChocolateyInstall\license\chocolatey.license.xml"

if ($licenseFile) {
if (Test-Path $licenseFile) {
# Add pro-only commands
$script:chocoCommands = @(
$script:chocoCommands
Expand All @@ -85,7 +85,7 @@ if ($licenseFile) {
$commandOptions.pin += " --note=''"

# Add Business-only commands and options if the license is a Business or Trial license
[xml]$xml = Get-Content -Path $licenseFile.FullName -ErrorAction Stop
[xml]$xml = Get-Content -Path $licenseFile -ErrorAction Stop
$licenseType = $xml.license.type

if ('Business', 'BusinessTrial' -contains $licenseType) {
Expand Down

0 comments on commit fe3151f

Please sign in to comment.