diff --git a/CHANGELOG.md b/CHANGELOG.md index 2973c2e..e3f2a0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes +## Version 3.13.5 + +- fix: MODULE_NOT_FOUND error #368 + ## Version 3.13.4 - fix: MODULE_NOT_FOUND error #368 diff --git a/bin/markdown-link-check b/bin/markdown-link-check index dab7111..26383e0 100755 --- a/bin/markdown-link-check +++ b/bin/markdown-link-check @@ -12,7 +12,68 @@ const pkg = require('../package.json'); const { Command } = require('commander'); const program = new Command(); const { ProxyAgent } = require('proxy-agent'); -const reporters = require('../reporters.js'); + +const reporters = { + default: async function defaultReporter(err, results, opts, filenameForOutput) { + const chalk = (await import('chalk')).default + + const statusLabels = { + alive: chalk.green('✓'), + dead: chalk.red('✖'), + ignored: chalk.gray('/'), + error: chalk.yellow('⚠'), + }; + + if (err) { + console.error(chalk.red("\n ERROR: something went wrong!")); + console.error(err.stack); + } + + if (results.length === 0 && !opts.quiet) { + console.log(chalk.yellow(" No hyperlinks found!")); + } + results.forEach(function (result) { + // Skip messages for non-deadlinks in quiet mode. + if (opts.quiet && result.status !== "dead") { + return; + } + + if (opts.verbose) { + if (result.err) { + console.log( + " [%s] %s → Status: %s %s", + statusLabels[result.status], + result.link, + result.statusCode, + result.err + ); + } else { + console.log(" [%s] %s → Status: %s", statusLabels[result.status], result.link, result.statusCode); + } + } else if (!opts.quiet) { + console.log(" [%s] %s", statusLabels[result.status], result.link); + } + }); + + if (!opts.quiet) { + console.log("\n %s links checked.", results.length); + } + + if (results.some((result) => result.status === "dead")) { + let deadLinks = results.filter((result) => { + return result.status === "dead"; + }); + if (!opts.quiet) { + console.error(chalk.red("\n ERROR: %s dead links found!"), deadLinks.length); + } else { + console.error(chalk.red("\n ERROR: %s dead links found in %s !"), deadLinks.length, filenameForOutput); + } + deadLinks.forEach(function (result) { + console.log(" [%s] %s → Status: %s", statusLabels[result.status], result.link, result.statusCode); + }); + } + }, +}; class Input { constructor(filenameForOutput, stream, opts) { diff --git a/default.js b/default.js deleted file mode 100644 index 5e0042b..0000000 --- a/default.js +++ /dev/null @@ -1,59 +0,0 @@ -module.exports = async function defaultReporter(err, results, opts, filenameForOutput) { - const chalk = (await import('chalk')).default - - const statusLabels = { - alive: chalk.green('✓'), - dead: chalk.red('✖'), - ignored: chalk.gray('/'), - error: chalk.yellow('⚠'), - }; - - if (err) { - console.error(chalk.red("\n ERROR: something went wrong!")); - console.error(err.stack); - } - - if (results.length === 0 && !opts.quiet) { - console.log(chalk.yellow(" No hyperlinks found!")); - } - results.forEach(function (result) { - // Skip messages for non-deadlinks in quiet mode. - if (opts.quiet && result.status !== "dead") { - return; - } - - if (opts.verbose) { - if (result.err) { - console.log( - " [%s] %s → Status: %s %s", - statusLabels[result.status], - result.link, - result.statusCode, - result.err - ); - } else { - console.log(" [%s] %s → Status: %s", statusLabels[result.status], result.link, result.statusCode); - } - } else if (!opts.quiet) { - console.log(" [%s] %s", statusLabels[result.status], result.link); - } - }); - - if (!opts.quiet) { - console.log("\n %s links checked.", results.length); - } - - if (results.some((result) => result.status === "dead")) { - let deadLinks = results.filter((result) => { - return result.status === "dead"; - }); - if (!opts.quiet) { - console.error(chalk.red("\n ERROR: %s dead links found!"), deadLinks.length); - } else { - console.error(chalk.red("\n ERROR: %s dead links found in %s !"), deadLinks.length, filenameForOutput); - } - deadLinks.forEach(function (result) { - console.log(" [%s] %s → Status: %s", statusLabels[result.status], result.link, result.statusCode); - }); - } -}; diff --git a/junit.js b/junit.js deleted file mode 100644 index 5fdbb83..0000000 --- a/junit.js +++ /dev/null @@ -1,36 +0,0 @@ -const { writeFileSync } = require('node:fs'); -const { create } = require('xmlbuilder2'); - -const doc = create({ version: '1.0', encoding: 'UTF-8' }) - .ele('testsuites'); - -module.exports = async function junitReporter(err, results, opts, filenameForOutput) { - const suite = doc.ele('testsuite', { name: filenameForOutput }); - - if (err) suite.ele('error', { message: err }) - else { - for (const result of results) { - const test = suite.ele('testcase', { classname: result.link }); - if (result.status !== 'dead') continue; - else { - if (result.err != null) { - test.ele('error', { - message: result.err, - type: 'error' - }); - } else { - test.ele('failure', { - message: result.err - ?? `${result.link} is ${result.status} (${result.statusCode})`, - type: result.status - }); - } - } - } - } - process.on('exit', () => { - writeFileSync('junit.xml', doc.end({ prettyPrint: true }) + '\n'); - console.error('\nWrote junit.xml'); - }); -}; - diff --git a/reporters.js b/reporters.js deleted file mode 100644 index 324fc73..0000000 --- a/reporters.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = { - default: require('./default.js'), - junit: require('./junit.js'), -};