mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge branch 'main' into verbose-logging
This commit is contained in:
commit
be6a6dccd9
62 changed files with 1243 additions and 41 deletions
|
|
@ -7,6 +7,10 @@ import { initializeCliArguments } from "./config/cliArguments.js";
|
|||
import { createSafeChainProxy } from "./registryProxy/registryProxy.js";
|
||||
import chalk from "chalk";
|
||||
|
||||
/**
|
||||
* @param {string[]} args
|
||||
* @returns {Promise<number | never[]>}
|
||||
*/
|
||||
export async function main(args) {
|
||||
process.on("SIGINT", handleProcessTermination);
|
||||
process.on("SIGTERM", handleProcessTermination);
|
||||
|
|
@ -14,6 +18,23 @@ export async function main(args) {
|
|||
const proxy = createSafeChainProxy();
|
||||
await proxy.startServer();
|
||||
|
||||
// Global error handlers to log unhandled errors
|
||||
process.on("uncaughtException", (error) => {
|
||||
ui.writeError(`Safe-chain: Uncaught exception: ${error.message}`);
|
||||
// @ts-expect-error writeVerbose will be added in a future PR
|
||||
ui.writeVerbose(`Stack trace: ${error.stack}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
ui.writeError(`Safe-chain: Unhandled promise rejection: ${reason}`);
|
||||
if (reason instanceof Error) {
|
||||
// @ts-expect-error writeVerbose will be added in a future PR
|
||||
ui.writeVerbose(`Stack trace: ${reason.stack}`);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
try {
|
||||
// This parses all the --safe-chain arguments and removes them from the args array
|
||||
args = initializeCliArguments(args);
|
||||
|
|
@ -52,7 +73,7 @@ export async function main(args) {
|
|||
// Returning the exit code back to the caller allows the promise
|
||||
// to be awaited in the bin files and return the correct exit code
|
||||
return packageManagerResult.status;
|
||||
} catch (error) {
|
||||
} catch (/** @type any */ error) {
|
||||
ui.writeError("Failed to check for malicious packages:", error.message);
|
||||
|
||||
// Returning the exit code back to the caller allows the promise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue