Skip to content

Commit

Permalink
Properly handle error while loading packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Nov 21, 2024
1 parent c199b3e commit 5846d4d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ export async function main() {
.command('list')
.description('List packages from registries')
.action(async () => {
const packageList = await packageManager.getPackageList();
const packages = packageList ? packageList.map((pkg) => `📦 ${pkg.name}`).join('\n') : null;

if (packages) {
console.log(packages);
try {
const packageList = await packageManager.getPackageList();
const packages = packageList ? packageList.map((pkg) => `📦 ${pkg.name}`).join('\n') : null;
if (packages && packages.length > 0) {
console.log(packages);
} else {
console.log("🤷 No packages found.")
}
} catch (error) {
console.error(error.message);
process.exit(1);
}
});

Expand Down

0 comments on commit 5846d4d

Please sign in to comment.