Skip to content

Commit

Permalink
fix: only print message for UsageErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jan 17, 2025
1 parent c7a9bde commit 8c4fbc8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sources/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {BaseContext, Builtins, Cli} from 'clipanion';
import type {UsageError} from 'clipanion';

Check warning on line 2 in sources/main.ts

View workflow job for this annotation

GitHub Actions / Testing chores

'UsageError' is defined but never used

import {version as corepackVersion} from '../package.json';

Expand Down Expand Up @@ -79,9 +80,17 @@ export async function runMain(argv: Array<string>) {
process.exitCode ??= code;
}
} else {
await engine.executePackageManagerRequest(request, {
cwd: process.cwd(),
args: restArgs,
});
try {
await engine.executePackageManagerRequest(request, {
cwd: process.cwd(),
args: restArgs,
});
} catch (error: UsageError | any) {
if (error?.name === `UsageError`) {
console.error(error.message);
process.exit(1);
}
throw error;
}
}
}

0 comments on commit 8c4fbc8

Please sign in to comment.