Skip to content

Commit

Permalink
update: add alive codes for matkdown-link-check to raise error only f…
Browse files Browse the repository at this point in the history
…or 404 (#12)
  • Loading branch information
holamgadol authored Feb 22, 2024
1 parent 36326e5 commit 2ee4208
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022
Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ Found 2 broken external links

FILE: src//linter-test-A.md

[✖] https://example.co/ → Status: 0
[✖] https://github.com/holamgadol/foliant-md-lint → Status: 404

--------------------------------------------------------------------------------

FILE: src//subproject/article.md

[✖] https://example.coms/ → Status: 0
[✖] https://github.com/holamgadol/foliant-md-linte → Status: 404

Full markdown-link-check log see in /Users/user/github/foliant-md-linter/.markdownlinkcheck.log
```
Expand Down
3 changes: 2 additions & 1 deletion configs/mdLinkCheckConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"pattern": "^(?!http).+"
}
],
"timeout": "20s"
"timeout": "20s",
"aliveStatusCodes": [200, 206, 0, 204, 401, 406]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foliant-md-linter",
"version": "0.1.11",
"version": "0.1.12",
"description": "CLI tool for linting Foliant markdown sources",
"license": "MIT",
"homepage": "https://github.com/holamgadol/foliant-md-linter",
Expand Down
2 changes: 1 addition & 1 deletion test/alt-src/linter-test-B.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ physics–science
![invalid link to image](/red-circle.png)
[Broken external link](https://example.rus/)
[Broken external link](https://github.com/holamgadol/foliant-md-linters)
```bash
indented-fence
Expand Down
40 changes: 20 additions & 20 deletions test/linter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@ test('urls -v', async () => {

`FILE: ${linkCheckFilePrint(linuxSwapString('src//linter-test-A.md', 'src//subproject/article.md'))}\n`,

` [✖] ${linuxSwapString('https://example.co/', 'https://example.coms/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-lint', 'https://github.com/holamgadol/foliant-md-linte')} → Status: 404\n`,

'--------------------------------------------------------------------------------\n',

`FILE: ${linkCheckFilePrint(linuxSwapString('src//subproject/article.md', 'src//linter-test-A.md'))}\n`,

` [✖] ${linuxSwapString('https://example.coms/', 'https://example.co/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-linte', 'https://github.com/holamgadol/foliant-md-lint')} → Status: 404\n`,

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['urls', '-v'], '.')
Expand All @@ -792,7 +792,7 @@ test('urls -v -s alt-src', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['urls', '-v', '-s alt-src'], '.')
Expand All @@ -810,7 +810,7 @@ test('urls -v -s alt-src -f', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['urls', '-v', '-s alt-src', '-f'], '.')
Expand Down Expand Up @@ -895,13 +895,13 @@ test('essential -v', async () => {

`FILE: ${linkCheckFilePrint(linuxSwapString('src//linter-test-A.md', 'src//subproject/article.md'))}\n`,

` [✖] ${linuxSwapString('https://example.co/', 'https://example.coms/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-lint', 'https://github.com/holamgadol/foliant-md-linte')} → Status: 404\n`,

'--------------------------------------------------------------------------------\n',

`FILE: ${linkCheckFilePrint(linuxSwapString('src//subproject/article.md', 'src//linter-test-A.md'))}\n`,

` [✖] ${linuxSwapString('https://example.coms/', 'https://example.co/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-linte', 'https://github.com/holamgadol/foliant-md-lint')} → Status: 404\n`,

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['essential', '-v'], '.')
Expand Down Expand Up @@ -943,13 +943,13 @@ test('essential -v -p another-project', async () => {

`FILE: ${linkCheckFilePrint(linuxSwapString('src//linter-test-A.md', 'src//subproject/article.md'))}\n`,

` [✖] ${linuxSwapString('https://example.co/', 'https://example.coms/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-lint', 'https://github.com/holamgadol/foliant-md-linte')} → Status: 404\n`,

'--------------------------------------------------------------------------------\n',

`FILE: ${linkCheckFilePrint(linuxSwapString('src//subproject/article.md', 'src//linter-test-A.md'))}\n`,

` [✖] ${linuxSwapString('https://example.coms/', 'https://example.co/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-linte', 'https://github.com/holamgadol/foliant-md-lint')} → Status: 404\n`,

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['essential', '-v', '-p another-project'], '.')
Expand Down Expand Up @@ -983,7 +983,7 @@ test('essential -s alt-src -v', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['essential', '-s alt-src', '-v'], '.')
Expand Down Expand Up @@ -1014,7 +1014,7 @@ test('essential -s alt-src -v -c', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['essential', '-s alt-src', '-v', '-c'], '.')
Expand Down Expand Up @@ -1045,7 +1045,7 @@ test('essential -s alt-src -v -c -f', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['essential', '-s alt-src', '-v', '-c', '-f'], '.')
Expand Down Expand Up @@ -1122,13 +1122,13 @@ test('full-check -v', async () => {

`FILE: ${linkCheckFilePrint(linuxSwapString('src//linter-test-A.md', 'src//subproject/article.md'))}\n`,

` [✖] ${linuxSwapString('https://example.co/', 'https://example.coms/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-lint', 'https://github.com/holamgadol/foliant-md-linte')} → Status: 404\n`,

'--------------------------------------------------------------------------------\n',

`FILE: ${linkCheckFilePrint(linuxSwapString('src//subproject/article.md', 'src//linter-test-A.md'))}\n`,

` [✖] ${linuxSwapString('https://example.coms/', 'https://example.co/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-linte', 'https://github.com/holamgadol/foliant-md-lint')} → Status: 404\n`,

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['full-check', '-v'], '.')
Expand Down Expand Up @@ -1172,13 +1172,13 @@ test('full-check -v -p another-project', async () => {

`FILE: ${linkCheckFilePrint(linuxSwapString('src//linter-test-A.md', 'src//subproject/article.md'))}\n`,

` [✖] ${linuxSwapString('https://example.co/', 'https://example.coms/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-lint', 'https://github.com/holamgadol/foliant-md-linte')} → Status: 404\n`,

'--------------------------------------------------------------------------------\n',

`FILE: ${linkCheckFilePrint(linuxSwapString('src//subproject/article.md', 'src//linter-test-A.md'))}\n`,

` [✖] ${linuxSwapString('https://example.coms/', 'https://example.co/')} → Status: 0\n`,
` [✖] ${linuxSwapString('https://github.com/holamgadol/foliant-md-linte', 'https://github.com/holamgadol/foliant-md-lint')} → Status: 404\n`,

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['full-check', '-v', '-p another-project'], '.')
Expand Down Expand Up @@ -1214,7 +1214,7 @@ test('full-check -s alt-src -v', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['full-check', '-s alt-src', '-v'], '.')
Expand Down Expand Up @@ -1247,7 +1247,7 @@ test('full-check -s alt-src -v -c', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['full-check', '-s alt-src', '-v', '-c'], '.')
Expand Down Expand Up @@ -1281,7 +1281,7 @@ test('full-check -s alt-src -v -c -l', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`,
`removing ${path.join(cwd, '.markdownlint-cli2.jsonc ...')}\n`,
Expand Down Expand Up @@ -1318,7 +1318,7 @@ test('full-check -s alt-src -v -c -f', async () => {

`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,

' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',

`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['full-check', '-s alt-src', '-v', '-c', '-f'], '.')
Expand Down Expand Up @@ -1356,7 +1356,7 @@ test('print -v', async () => {
`Full markdownlint log see in ${path.join(cwd, '.markdownlint_full.log')}\n`,
'Found 1 broken external links\n',
`FILE: ${linkCheckFilePrint('alt-src//linter-test-B.md')}\n`,
' [✖] https://example.rus/ → Status: 0\n',
' [✖] https://github.com/holamgadol/foliant-md-linters → Status: 404\n',
`Full markdown-link-check log see in ${path.join(cwd, '.markdownlinkcheck.log')}\n`]
const result = await cli(['print', '-v'], '.', false)
console.log(result)
Expand Down
2 changes: 1 addition & 1 deletion test/src/linter-test-A.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ physics–science
![invalid link to image](/red-circle.png)
[Broken external link](https://example.co/)
[Broken external link](https://github.com/holamgadol/foliant-md-lint)
[absolute link to file](/another-project/subproject/article)
Expand Down
2 changes: 1 addition & 1 deletion test/src/subproject/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ tags:

[broken local link](#anchor)

[broken external link](https://example.coms/)
[broken external link](https://github.com/holamgadol/foliant-md-linte)

0 comments on commit 2ee4208

Please sign in to comment.