markdown_link_checker_sc 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +20 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -43,12 +43,14 @@ async function loadJSONFileToReportOn(filePath) {
43
43
  try {
44
44
  const fileContent = await fs.promises.readFile(filePath, "utf8");
45
45
  let filesArray = JSON.parse(fileContent);
46
- // Values default to option directory if not specified
47
- if (!options.root) {
48
- options.root = options.directory;
46
+ // Prepend the full path - either from root or directory
47
+ if (options.root) {
48
+ filesArray = filesArray.map((str) => path.join(options.root, str));
49
+ } else {
50
+ //
51
+ filesArray = filesArray.map((str) => path.join(options.directory, str));
49
52
  }
50
- // Prepend the full path.
51
- filesArray = filesArray.map((str) => path.join(options.root, str));
53
+
52
54
  //console.log(filesArray);
53
55
  return filesArray;
54
56
  } catch (error) {
@@ -449,7 +451,14 @@ function outputErrors(results) {
449
451
 
450
452
  //console.log(sortedByPageErrors);
451
453
  for (page in sortedByPageErrors) {
452
- console.log(`\n${page}`);
454
+ let pageFromRoot;
455
+ if (options.root) {
456
+ pageFromRoot = page.split(options.root)[1];
457
+ } else {
458
+ pageFromRoot = page.split(options.directory)[1];
459
+ }
460
+
461
+ console.log(`\n${pageFromRoot}`);
453
462
  for (const error of sortedByPageErrors[page]) {
454
463
  if (error.type == "InternalLinkMissingFile") {
455
464
  console.log(`- ${error.type}: ${error.linkUrl}`);
@@ -459,8 +468,12 @@ function outputErrors(results) {
459
468
  // missing anchor in linked file that exists.
460
469
  //console.log(error);
461
470
  console.log(
462
- `- ${error.type}: #${error.linkAnchor} (not found in current file)`
471
+ `- ${error.type}: ` +
472
+ "`[" +
473
+ `${error.linkText}](#${error.linkAnchor})` +
474
+ "` (Internal link without matching heading name or element id)"
463
475
  );
476
+ //console.log( `- ${error.type}: #${error.linkAnchor} (Internal link without matching heading name or element id)` );
464
477
  //console.log(` ${error.type}: #${error.linkAnchor} (heading/anchor missing?)`);
465
478
  //console.log(` #${error.linkAnchor} - Internal anchor not found`);
466
479
  //console.log(` [${error.linkText}](#${error.linkAnchor}) - Anchor not found`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown_link_checker_sc",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Markdown Link Checker",
5
5
  "main": "index.js",
6
6
  "scripts": {