mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2026-05-25 09:43:14 +08:00
fix(packages): fix ERR_USE_AFTER_CLOSE error when pressing Ctrl+C during commit
This commit is contained in:
@@ -42,7 +42,18 @@ export async function gitCommit(lang: Lang = 'en-us') {
|
|||||||
message: `${value.padEnd(30)} (${msg})`
|
message: `${value.padEnd(30)} (${msg})`
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const result = await prompt<PromptObject>([
|
// Suppress ERR_USE_AFTER_CLOSE thrown by enquirer's readline cleanup on Ctrl+C (Node.js v24+)
|
||||||
|
const errorHandler = (error: NodeJS.ErrnoException) => {
|
||||||
|
if (error.code === 'ERR_USE_AFTER_CLOSE') {
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
process.on('uncaughtException', errorHandler);
|
||||||
|
|
||||||
|
let result: PromptObject;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = await prompt<PromptObject>([
|
||||||
{
|
{
|
||||||
name: 'types',
|
name: 'types',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
@@ -61,6 +72,11 @@ export async function gitCommit(lang: Lang = 'en-us') {
|
|||||||
message: gitCommitMessages.description
|
message: gitCommitMessages.description
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
} catch {
|
||||||
|
process.exit(0);
|
||||||
|
} finally {
|
||||||
|
process.off('uncaughtException', errorHandler);
|
||||||
|
}
|
||||||
|
|
||||||
const breaking = result.description.startsWith('!') ? '!' : '';
|
const breaking = result.description.startsWith('!') ? '!' : '';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user