Git Product home page Git Product logo

Comments (9)

MichaIng avatar MichaIng commented on August 11, 2024 1

Or use extended globs to check all Markdown files in all directories below the current one recursively:

lychee -v '**/*.md'

Note the required single quotes since lychee itself does the file matching here as extended globs (** to match directories recursively) are not supported by default in most shells.

from lychee.

mre avatar mre commented on August 11, 2024 1

We use glob for that. According to the docs about patterns,

** matches the current directory and arbitrary subdirectories. This sequence must form a single path component, so both a and b are invalid and will result in an error. A sequence of more than two consecutive * characters is also invalid.

This also explains why **.md doesn't work: ** can only stand on its own.

Just checked if lychee was picking up the current directory when using a glob.
Created the following file tree:

❯❯❯ tree
.
├── 1
│   └── bar.md
├── 2
│   ├── 3
│   │   └── bla.md
│   └── baz.md
└── foo.md

3 directories, 4 files

Here's the glob test for ls:

ls **/*.md
1/bar.md   2/3/bla.md 2/baz.md   foo.md

And here's the lychee command:

❯❯❯ lychee --verbose --progress '**/*.md'
✅ http://foo.com/ [200 OK]
✅ http://bla.com/ [200 OK]
✅ http://baz.com/ [200 OK]
✅ http://bar.com/ [200 OK]

📝 Summary
-------------------
🔍 Total: 4
✅ Successful: 4
⏳ Timeouts: 0
🔀 Redirected: 0
👻 Excluded: 0
🚫 Errors: 0

So it did pick up http://foo.com. 😃 Also works without the quotes around **/*.md on zsh.

from lychee.

mre avatar mre commented on August 11, 2024

Yeah, just use multiple arguments:

lychee --verbose 1/*.md 2/*.md

There is no limit on the maximum number of inputs. You can also mix inputs from different sources:

lychee --verbose 1/*.md 2/*.md https://endler.dev

This checks the markdown files in the folders 1 and 2 as well as all links on endler.dev. 😃

from lychee.

mre avatar mre commented on August 11, 2024

@Wuliyuanulb can we close this or do you have any follow-up questions?

from lychee.

joesan avatar joesan commented on August 11, 2024

I have a question on this one. How do I specify a root directory under which I want all the markdown files scanned for broken link?

from lychee.

MichaIng avatar MichaIng commented on August 11, 2024
lychee -v '/path/to/**/*.md'

or

cd /path/to
lychee -v '**/*.md'

with /path/to being the path to that root directory.

Btw @mre is ** expanded to . (current directory) as well or why does it work? I once tried **.md to assure that everything including the current dir is checked, but that does not work. **/*.md does exactly this, even that it looks like it scans only sub directories recursively while skipping the current dir. ** => . would make sense, but it was not intuitive to me in the first place 😄.

from lychee.

mre avatar mre commented on August 11, 2024

That should answer all questions and we can close this I guess. 😄

from lychee.

MichaIng avatar MichaIng commented on August 11, 2024

Also works without the quotes around **/*.md on zsh.

True, but if the shell did not support it or has ** support disabled (default in bash), the shell could theoretically expand * and lychee would then get a glob with * pre-expanded, hence won't find all matches anymore. It's unlikely that there is a file path with literal **, but I like to be explicit when spamming shell commands into the world 😄.

from lychee.

mre avatar mre commented on August 11, 2024

Oh yeah, absolutely. I recommend to always quote it so that there are no differences with varying environments. Thanks for pointing that out. 👍

from lychee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.