From fe3151f9ec5e0e0dc2614ff517b3d2b9b1e4ce2e Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Tue, 20 Jun 2023 08:53:50 -0700 Subject: [PATCH] (#3218) Update Tab Expansion to use Test-Path 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. --- .../helpers/ChocolateyTabExpansion.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 index 1d707b28dd..89cdff9539 100644 --- a/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 +++ b/src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1 @@ -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"); @@ -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 @@ -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) {