Skip to content

Commit

Permalink
Fix warning for impossible directories
Browse files Browse the repository at this point in the history
Closes GH-54.
  • Loading branch information
wooorm committed Jun 11, 2020
1 parent f3a325b commit cc4c1b3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/check/check-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function checkIfReferencedFilesExist(ctx, next) {
fs.access(filePath, fs.F_OK, onaccess)

function onaccess(err) {
var noEntry = err && err.code === 'ENOENT'
var noEntry = err && (err.code === 'ENOENT' || err.code === 'ENOTDIR')

landmarks[filePath] = {'': !noEntry}

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/file-as-folder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[](file-as-folder.md/other)

This comment has been minimized.

Copy link
@oleorhagen

oleorhagen Jun 11, 2020

Maybe add a self-referential case also?
i.e.:

[](../fixtures/file-as-folder.md/other)

This comment has been minimized.

Copy link
@wooorm

wooorm Jun 11, 2020

Author Member

I was under the impression that that is not important. Do you mean to say that your initial problem still persists?

This comment has been minimized.

Copy link
@oleorhagen

oleorhagen Jun 11, 2020

Seems to still be there for this case

This comment has been minimized.

Copy link
@wooorm

wooorm Jun 11, 2020

Author Member

Please npm update to get this patch. Or otherwise provide more information. It works for me.

Screen Shot 2020-06-11 at 4 08 05 pm

This comment has been minimized.

Copy link
@oleorhagen

oleorhagen Jun 11, 2020

Alright, I've probably messed up. Thanks :)

This comment has been minimized.

Copy link
@wooorm

wooorm Jun 11, 2020

Author Member

Do let me know if I’m wrong, it could be that it is important, but I strongly don’t think that’s what caused it!

Thanks for using remark-validate-links and do let us know if you run into more things!

35 changes: 35 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,41 @@ test('remark-validate-links', function (t) {
}
})

t.test('should warn on files as folders', function (st) {
st.plan(1)

childProcess.exec(
[
bin,
'--no-config',
'--no-ignore',
'--use',
'../..',
'--use',
'../sort',
'file-as-folder.md'
].join(' '),
onexec
)

function onexec(err, stdout, stderr) {
st.deepEqual(
[err, strip(stderr)],
[
null,
[
'file-as-folder.md',
' 1:1-1:28 warning Link to unknown file: `file-as-folder.md/other`. Did you mean `file-as-folder.md` missing-file remark-validate-links',
'',
'⚠ 1 warning',
''
].join('\n')
],
'should work'
)
}
})

t.test('should check images', function (st) {
st.plan(1)

Expand Down

0 comments on commit cc4c1b3

Please sign in to comment.