Skip to content

Commit

Permalink
Fix unit test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Sep 15, 2024
1 parent 49e5047 commit cc848c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom
// Calculate lines of code
const loc = { total: 0, content: 0, code: 0 };
if (opts.calculateLines) {
// TODO: catch error?
const fileContent = (manualFileContent[files.indexOf(file)] ?? fs.readFileSync(file).toString()) ?? '';
const allLines = fileContent.split(/\r?\n/gm);
loc.total = allLines.length;
Expand Down
6 changes: 3 additions & 3 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function test([filename, fileContent = ''], [type, testVal]) {
}
else {
errors++;
console.error(`- #${i} failed: '${filename}' is ${testContent} instead of ${testVal}`);
console.error(`! #${i} failed: '${filename}' is ${testContent} instead of ${testVal}`);
}
}

Expand Down Expand Up @@ -80,8 +80,8 @@ async function unitTest() {
await test(['unknown'], ['files', null]);

if (errors) {
const message = `\nExited with ${errors} errors.\n`;
throw console.error(message), message;
console.error(`\n! Exited with ${errors} errors.\n`);
return;
}
else console.info('All unit tests passed');
}
Expand Down

0 comments on commit cc848c9

Please sign in to comment.