Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only print message for UsageErrors #602

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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;
}
}
}
Loading