All files / lib debug.ts

21.43% Statements 3/14
12.5% Branches 1/8
50% Functions 1/2
23.08% Lines 3/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26      2x                                   2x     2x  
/* eslint-disable @typescript-eslint/no-var-requires */
let debug: Function;
 
Iif (process.env.DEBUG === "makitso") {
  const fs = require("fs");
  const prettyjson = require("prettyjson");
  const chalk = require("chalk");
  const cwd = process.cwd();
  debug = (...stuff: any[]) => {
    if (stuff.length === 1) {
      stuff = stuff[0];
    }
    const at = new Error().stack
      ?.split(/\n/)[2]
      .trim()
      .replace(cwd, "");
    const record = prettyjson.render(stuff, {});
    fs.appendFileSync("debug.log", `${chalk.blue(at)}\n${record}\n`);
  };
} else {
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  debug = () => {};
}
 
export { debug };