mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 20:20:49 +00:00
Add type information for new functions.
This commit is contained in:
parent
be6a6dccd9
commit
932ea6b8f9
3 changed files with 14 additions and 3 deletions
|
|
@ -9,7 +9,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run test --workspace=packages/safe-chain --workspace=packages/safe-chain-bun",
|
"test": "npm run test --workspace=packages/safe-chain --workspace=packages/safe-chain-bun",
|
||||||
"test:e2e": "npm run test --workspace=test/e2e",
|
"test:e2e": "npm run test --workspace=test/e2e",
|
||||||
"lint": "npm run lint --workspace=packages/safe-chain"
|
"lint": "npm run lint --workspace=packages/safe-chain",
|
||||||
|
"typecheck": "npm run typecheck --workspace=packages/safe-chain"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ import {
|
||||||
LOGGING_VERBOSE,
|
LOGGING_VERBOSE,
|
||||||
} from "../config/settings.js";
|
} from "../config/settings.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {{ bufferOutput: boolean, bufferedMessages:(() => void)[]}}
|
||||||
|
*/
|
||||||
const state = {
|
const state = {
|
||||||
bufferOutput: false,
|
bufferOutput: false,
|
||||||
bufferedMessages: [],
|
bufferedMessages: [],
|
||||||
|
|
@ -72,12 +75,21 @@ function writeExitWithoutInstallingMaliciousPackages() {
|
||||||
writeOrBuffer(() => console.error(message));
|
writeOrBuffer(() => console.error(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} message
|
||||||
|
* @param {...any} optionalParams
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
function writeVerbose(message, ...optionalParams) {
|
function writeVerbose(message, ...optionalParams) {
|
||||||
if (!isVerboseMode()) return;
|
if (!isVerboseMode()) return;
|
||||||
|
|
||||||
writeOrBuffer(() => console.log(message, ...optionalParams));
|
writeOrBuffer(() => console.log(message, ...optionalParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {() => void} messageFunction
|
||||||
|
*/
|
||||||
function writeOrBuffer(messageFunction) {
|
function writeOrBuffer(messageFunction) {
|
||||||
if (state.bufferOutput) {
|
if (state.bufferOutput) {
|
||||||
state.bufferedMessages.push(messageFunction);
|
state.bufferedMessages.push(messageFunction);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ export async function main(args) {
|
||||||
// Global error handlers to log unhandled errors
|
// Global error handlers to log unhandled errors
|
||||||
process.on("uncaughtException", (error) => {
|
process.on("uncaughtException", (error) => {
|
||||||
ui.writeError(`Safe-chain: Uncaught exception: ${error.message}`);
|
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}`);
|
ui.writeVerbose(`Stack trace: ${error.stack}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
@ -29,7 +28,6 @@ export async function main(args) {
|
||||||
process.on("unhandledRejection", (reason) => {
|
process.on("unhandledRejection", (reason) => {
|
||||||
ui.writeError(`Safe-chain: Unhandled promise rejection: ${reason}`);
|
ui.writeError(`Safe-chain: Unhandled promise rejection: ${reason}`);
|
||||||
if (reason instanceof Error) {
|
if (reason instanceof Error) {
|
||||||
// @ts-expect-error writeVerbose will be added in a future PR
|
|
||||||
ui.writeVerbose(`Stack trace: ${reason.stack}`);
|
ui.writeVerbose(`Stack trace: ${reason.stack}`);
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue