diff --git a/markdown-link-check b/markdown-link-check index 8739690..06dc8f7 100755 --- a/markdown-link-check +++ b/markdown-link-check @@ -451,7 +451,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; else return; } diff --git a/package-lock.json b/package-lock.json index b8fa2d8..47f3959 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "markdown-link-check", - "version": "3.14.0", + "version": "3.14.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "markdown-link-check", - "version": "3.14.0", + "version": "3.14.1", "license": "ISC", "dependencies": { "async": "^3.2.6", diff --git a/package.json b/package.json index 28db2a4..cb2e4d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "markdown-link-check", - "version": "3.14.0", + "version": "3.14.1", "description": "checks the all of the hyperlinks in a markdown text to determine if they are alive or dead", "bin": { "markdown-link-check": "markdown-link-check" diff --git a/test/markdown-link-check.test.js b/test/markdown-link-check.test.js index 06a8768..5442e2b 100644 --- a/test/markdown-link-check.test.js +++ b/test/markdown-link-check.test.js @@ -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; @@ -442,4 +443,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!'); + }); + }); });