Skip to content

Commit

Permalink
feat: 🎸 handle terminal signals to kill the process
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofcferreira committed Dec 4, 2024
1 parent 396a0cb commit 97fe1ad
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ async function runCoCommitFlow({
if (!knownCoAuthors.length) {
console.info(
chalk.yellow(
`No co-authors configured in the config file (${coAuthorsFile}!`,
),
`No co-authors configured in the config file (${coAuthorsFile}!`
)
);
return;
}
Expand All @@ -44,6 +44,14 @@ async function runCoCommitFlow({
updateCommitMessageWithCoAuthors(commitFile, authorsList);
}

process.on("SIGINT", () => {
process.exit(1);
});

process.on("SIGKILL", () => {
process.exit(1);
});

yargs(hideBin(process.argv))
.usage("Usage: $0 -f [commit message file]")
.command(
Expand Down Expand Up @@ -73,10 +81,10 @@ yargs(hideBin(process.argv))
})
.catch((e) => {
console.error(
chalk.red(`πŸš’ Failed to add co-authors to the commit: ${e}`),
chalk.red(`πŸš’ Failed to add co-authors to the commit: ${e}`)
);
});
},
}
)
.command({
command: "add-coauthor <name> <email>",
Expand All @@ -99,7 +107,7 @@ yargs(hideBin(process.argv))
});
} catch (e) {
console.error(
chalk.red(`πŸš’ Failed to add co-author to the config file: ${e}`),
chalk.red(`πŸš’ Failed to add co-author to the config file: ${e}`)
);
}
},
Expand Down

0 comments on commit 97fe1ad

Please sign in to comment.