Skip to content

Commit

Permalink
Fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrossum committed Dec 23, 2020
1 parent 0c4d0e4 commit 2cc9ee6
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const exit = () => process.exit(1);

export function runTests(r, paths) {
console.clear();
paths.forEach(path => {
paths.forEach((path) => {
r(path);
});
}
Expand All @@ -17,8 +17,7 @@ export function runTests(r, paths) {
// };

export const test = (name, fn) => {
global.console.log(
name
global.console.log(name);
fn();
};

Expand All @@ -41,14 +40,14 @@ export const assert = (desc, cond, exitFn?) => {
const [, , lineNumber] = line.split(':');

global.console.log(
indent(
reindent(cond.toString()),
(line, n) =>
` ${
chalk.blue(Number(lineNumber) + n)
// + lineNumber
} ${chalk.grey('│')} ${cardinal.highlight(line)}`
)
indent(
reindent(cond.toString()),
(line, n) =>
` ${
chalk.blue(Number(lineNumber) + n)
// + lineNumber
} ${chalk.grey('│')} ${cardinal.highlight(line)}`
)
);
const [line1, , line2] = stackLines
? stackLines.slice(2, stackLines.length - 6)
Expand All @@ -69,14 +68,14 @@ function reindent(text) {
let indentationToRemove = Infinity;
const lines = text.split('\n');
const [firstLine, ...rest] = lines;
rest.forEach(line => {
rest.forEach((line) => {
const indentation = line.length - line.trimStart().length;
if (indentation < indentationToRemove) indentationToRemove = indentation;
});

return [
firstLine.trimStart(),
...rest.map(line => line.substring(indentationToRemove)),
...rest.map((line) => line.substring(indentationToRemove)),
].join('\n');
}

Expand Down

0 comments on commit 2cc9ee6

Please sign in to comment.