From a86905bc68ce60e8351cb04424a364e81c37d6be Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Fri, 26 Jan 2024 17:05:18 +0000 Subject: [PATCH] global: Program error on getInstalledPackages error. --- src/lib/runGlobal.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/lib/runGlobal.ts b/src/lib/runGlobal.ts index 47011f8c..3d4c91a5 100644 --- a/src/lib/runGlobal.ts +++ b/src/lib/runGlobal.ts @@ -5,6 +5,7 @@ import { Options } from '../types/Options' import chalk from './chalk' import getInstalledPackages from './getInstalledPackages' import { keyValueBy } from './keyValueBy' +import programError from './programError' import upgradePackageDefinitions from './upgradePackageDefinitions' /** Checks global dependencies for upgrades. */ @@ -13,19 +14,24 @@ async function runGlobal(options: Options): Promise | void> { printSorted(options, options, 'verbose') print(options, '\nGetting installed packages', 'verbose') - const globalPackages = await getInstalledPackages( - pick(options, [ - 'cli', - 'cwd', - 'filter', - 'filterVersion', - 'global', - 'packageManager', - 'prefix', - 'reject', - 'rejectVersion', - ]), - ) + let globalPackages: Index = {} + try { + globalPackages = await getInstalledPackages( + pick(options, [ + 'cli', + 'cwd', + 'filter', + 'filterVersion', + 'global', + 'packageManager', + 'prefix', + 'reject', + 'rejectVersion', + ]), + ) + } catch (e: any) { + programError(options, e.message) + } print(options, 'globalPackages:', 'verbose') print(options, globalPackages, 'verbose')