markdown_link_checker_sc 0.0.3 → 0.0.5

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 +35 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -20,8 +20,16 @@ program
20
20
  "Try a markdown file extension check if a link to HTML fails.",
21
21
  true
22
22
  )
23
+ .option(
24
+ "-f, --files <files...>",
25
+ "List of files to process (path relative to -d). Default is all files.",
26
+ []
27
+ )
23
28
  .parse(process.argv);
24
29
 
30
+ // TODO PX4 special parsing - errors or pages we exclude by default.
31
+ // Particular error types on particular pages?
32
+
25
33
  const options = program.opts();
26
34
 
27
35
  const isMarkdown = (file) => path.extname(file).toLowerCase() === ".md";
@@ -368,10 +376,35 @@ function processRelativeLinks(results) {
368
376
  function outputResults(results) {
369
377
  //console.log(results.allErrors);
370
378
 
379
+ // Strip out any files that are not in options.files
380
+ // if this is empty skip step
381
+ // These are path relative, so we will need to
382
+ //console.log(`File options: ${options.files}`);
383
+
384
+ let resultsForSpecifiedFiles=results.allErrors;
385
+ if (options.files.length > 0) {
386
+ resultsForSpecifiedFiles = results.allErrors.filter((error) => {
387
+ //console.log(`Error: ${error}`);
388
+ //console.log(JSON.stringify(error, null, 2));
389
+ //console.log(`Error page: ${error.page}`);
390
+ //Strip off the directory prefix for comparison to passed values (which must not start with / or \)
391
+ let pathOnly = error.page.split(options.directory)[1];
392
+ if (pathOnly.startsWith("/") || pathOnly.startsWith("\\")) {
393
+ pathOnly = pathOnly.slice(1);
394
+ }
395
+ //console.log(`Pathonly: ${pathOnly}`);
396
+ return options.files.includes(pathOnly);
397
+ });
398
+
399
+ //console.log(resultsForSpecifiedFiles);
400
+ }
401
+
371
402
  //Sort results by page and type.
372
- // Perhaps next step is to create only get info for paricular pages.
403
+ // Perhaps next step is to create only get info for particular pages.
373
404
  const sortedByPageErrors = {};
374
- for (const error of results.allErrors) {
405
+
406
+ //for (const error of results.allErrors) {
407
+ for (const error of resultsForSpecifiedFiles) { //Report errors for listed pages or all
375
408
  //console.log("error:");
376
409
  //console.log(error);
377
410
  //console.log(error.page);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown_link_checker_sc",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Markdown Link Checker",
5
5
  "main": "index.js",
6
6
  "scripts": {