tcort / markdown-link-check

checks all of the hyperlinks in a markdown text to determine if they are alive or dead
ISC License
577 stars 116 forks source link

Add native globbing of files #40

Open nschonni opened 6 years ago

nschonni commented 6 years ago

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.

timmkrause commented 6 years ago

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 commented 6 years ago

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

timmkrause commented 6 years ago

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.

nschonni commented 6 years ago

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

timmkrause commented 6 years ago

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

image

timmkrause commented 6 years ago

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.

nvuillam commented 2 years ago

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 :)

nschonni commented 2 years ago

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

iamtodor commented 2 years ago

@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

vchelamkuri commented 2 years ago

Any update on the support for native globbing?

CanadaHonk commented 11 months ago
  • 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

per1234 commented 9 months ago

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?