markdown-link-check icon indicating copy to clipboard operation
markdown-link-check copied to clipboard

Add native globbing of files

Open nschonni opened this issue 6 years ago • 12 comments

The example in the repo works on systems that have find, but not so much in a Windows world https://github.com/tcort/markdown-link-check#check-links-from-a-local-markdown-folder-recursive Maybe use https://www.npmjs.com/package/glob to try and parse the file parameter as a file glob and iterate over it in the CLI.

nschonni avatar May 16 '18 19:05 nschonni

Like the idea. Having the same „problem“ but found a way (guess there are more) to work around it. I am using „cmder“ to have find available.

But yes, native support would be great and make the usage much easier for recursive executions.

timmkrause avatar May 16 '18 20:05 timmkrause

This would also enable statistic counters across multiple files: Number of errors, error percentage etc.

timmkrause avatar May 17 '18 08:05 timmkrause

Will start with this topic when #41 has been accepted. My next time slot is Friday afternoon, I hope the changes have been merged then.

timmkrause avatar May 23 '18 06:05 timmkrause

It may be worth looking at how https://github.com/igorshubovych/markdownlint-cli does it

nschonni avatar May 23 '18 09:05 nschonni

Now working on it but I won't finish it today.

image

timmkrause avatar Jun 05 '18 19:06 timmkrause

Sorry. Have been pretty busy the last 2 weeks and now I am 3 weeks on vacation. Will get back to this topic if nobody foreruns me.

Current state: https://github.com/timmkrause/markdown-link-check/tree/feature/globs

There are still a few issues (and a critical one regarding async) that needs to be fixed. I was also thinking about moving the logic into separate "analyzers" like the protocol handlers in link-check.

Feel free to finish this work, otherwise I will get back to it in the mid of July.

timmkrause avatar Jun 14 '18 19:06 timmkrause

Hi, any news about this PR ? To enhance integration off markdown-link-check within MegaLinter, it would help a lot to be able to run:

markdown-link-check file1.md file2.md file3.md

Thansk a lot :)

nvuillam avatar Jan 29 '22 21:01 nvuillam

Think this was mostly done in https://github.com/tcort/markdown-link-check/pull/179 @tcort the 2 outstanding cleanups

  • [ ] an -i/--ignore flag to excluded files from the globs. EX: markdown-link-check "**/*.md" -i node_modules/. There are probably other use cases, but primarily needed so it can glob at the root, without picking up files in node_modules. Alternately a default ignore for node_modules might be enough
  • [ ] Update the documentation around globbing https://github.com/tcort/markdown-link-check#check-links-from-a-local-markdown-folder-recursive

nschonni avatar Apr 03 '22 15:04 nschonni

@nschonni I'd also suggest along with node_modules you can consider adding .history dir to be excluded from the VS-Code plugin https://marketplace.visualstudio.com/items?itemName=xyz.local-history

iamtodor avatar Jun 22 '22 15:06 iamtodor

Any update on the support for native globbing?

vchelamkuri avatar Jul 18 '22 20:07 vchelamkuri

  • an -i/--ignore flag to excluded files from the globs. EX: markdown-link-check "**/*.md" -i node_modules/. There are probably other use cases, but primarily needed so it can glob at the root, without picking up files in node_modules. Alternately a default ignore for node_modules might be enough

See also #102

CanadaHonk avatar Oct 17 '23 17:10 CanadaHonk

Think this was mostly done in https://github.com/tcort/markdown-link-check/pull/179

I'd be happy to be wrong, but I don't think so. Although a very important advancement, https://github.com/tcort/markdown-link-check/pull/179 did not add the globbing support requested here at all.

If I run the command @nschonni's comment implies as being supported following https://github.com/tcort/markdown-link-check/pull/179, I simply get the error we would expect if the "globstar" globbing syntax was not supported:

$ markdown-link-check --version
3.11.2

$ markdown-link-check "**/*.md"
node:fs:1583
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, stat '**/*.md'
    at Object.statSync (node:fs:1583:3)
    at Command.<anonymous> (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/markdown-link-check:79:38)
    at Command.listener [as _actionHandler] (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/node_modules/commander/lib/command.js:482:17)
    at /mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/node_modules/commander/lib/command.js:1283:65
    at Command._chainOrCall (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/node_modules/commander/lib/command.js:1177:12)
    at Command._parseCommand (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/node_modules/commander/lib/command.js:1283:27)
    at Command.parse (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/node_modules/commander/lib/command.js:909:10)
    at getInputs (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/markdown-link-check:91:7)
    at main (/mnt/1c0bd221-e077-452c-b688-160dc700c122/git/tooling-project-assets/node_modules/markdown-link-check/markdown-link-check:235:20) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '**/*.md'
}

@nschonni do you get a different result?

per1234 avatar Dec 01 '23 03:12 per1234