33 lines
782 B
TypeScript
33 lines
782 B
TypeScript
import process from "node:process";
|
|
import chalk from "chalk";
|
|
|
|
import {TestOutput} from "./code-output.ts";
|
|
|
|
export const debugPrintOutput = async (header: string, files: TestOutput[]) => {
|
|
const out = [];
|
|
|
|
const headFn = chalk.bgCyan;
|
|
const headPadding = header.split('').map(x=>'#').join('');
|
|
out.push(...[
|
|
headFn(`##${headPadding}##`),
|
|
headFn(`# ${header} #`),
|
|
headFn(`##${headPadding}##`),
|
|
]);
|
|
|
|
const fileHeadFn = chalk.blue;
|
|
const fileContentFn = chalk.blackBright;
|
|
out.push(...(files.map(file=>{
|
|
return [
|
|
fileHeadFn(`${file.fileName}:`),
|
|
fileContentFn(`${file.code??file.source}`),
|
|
'',
|
|
]
|
|
}).flat()));
|
|
|
|
out.push(...[
|
|
headFn(`##${headPadding}##`),
|
|
]);
|
|
|
|
process.env.DEBUG? console.log(out.join('\n')) : null;
|
|
};
|