Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion markdown-link-check
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ async function runMarkdownLinkCheck(filenameForOutput, markdown, opts) {
));

if (err) throw null;
else if (results.some((result) => result.status === 'dead')) return;
else if (results.some((result) => result.status === 'dead')) throw null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have enabled the workflows. I'm hoping a test will fail as a result of this change. If not, we should add one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I'll try to add some test case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test cases dc70b82

else return;
}

Expand Down
18 changes: 18 additions & 0 deletions test/markdown-link-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = require('path');
const expect = require('expect.js');
const http = require('http');
const express = require('express');
const child_process = require('child_process');
const markdownLinkCheck = require('../');
const dirname = process.platform === 'win32' ? __dirname.replace(/\\/g, '/') : __dirname;

Expand Down Expand Up @@ -436,4 +437,21 @@ describe('markdown-link-check', function () {
done();
});
});

describe("CLI", function () {
const cliPath = path.join(__dirname, '..', 'markdown-link-check');

it("exits with 0 if all links are ok", function () {
const { status, output } = child_process.spawnSync(process.execPath, [cliPath, path.join(__dirname, 'alive-links-only.md')]);
expect(status).to.be(0);
expect(output.toString()).to.contain('links checked.');
});

it("exits with 1 if any link is broken", function () {
this.timeout(60000)
const { status, output } = child_process.spawnSync(process.execPath, [cliPath, [path.join(__dirname, 'section-links.md')]]);
expect(status).to.be(1);
expect(output.toString()).to.contain('dead links found!');
});
});
});
Loading