Skip to content

Commit ea89b42

Browse files
authoredFeb 21, 2021
fix: do not include skipped links in the final link count (#277)
1 parent 245b3bd commit ea89b42

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎src/cli.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ async function main() {
246246
}
247247

248248
const total = (Date.now() - start) / 1000;
249-
249+
const scannedLinks = result.links.filter(x => x.state !== LinkState.SKIPPED);
250250
if (!result.passed) {
251251
const borked = result.links.filter(x => x.state === LinkState.BROKEN);
252252
logger.error(
253253
chalk.bold(
254254
`${chalk.red('ERROR')}: Detected ${
255255
borked.length
256256
} broken links. Scanned ${chalk.yellow(
257-
result.links.length.toString()
257+
scannedLinks.length.toString()
258258
)} links in ${chalk.cyan(total.toString())} seconds.`
259259
)
260260
);
@@ -264,7 +264,7 @@ async function main() {
264264
logger.error(
265265
chalk.bold(
266266
`🤖 Successfully scanned ${chalk.green(
267-
result.links.length.toString()
267+
scannedLinks.length.toString()
268268
)} links in ${chalk.cyan(total.toString())} seconds.`
269269
)
270270
);

‎test/test.cli.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ describe('cli', function () {
6262
'"LICENSE.md, unlinked.md"',
6363
'test/fixtures/markdown/README.md',
6464
]);
65-
assert.match(stripAnsi(res.stdout), /\[SKP\]/);
65+
const stdout = stripAnsi(res.stdout);
66+
const stderr = stripAnsi(res.stderr);
67+
assert.match(stdout, /\[SKP\]/);
68+
// make sure we don't report skipped links in the count
69+
assert.match(stderr, /scanned 2 links/);
6670
});
6771

6872
it('should provide CSV if asked nicely', async () => {

0 commit comments

Comments
 (0)
Please sign in to comment.