Skip to content

Commit

Permalink
fix: more error handling for files that will never contain docblocks (#…
Browse files Browse the repository at this point in the history
…321)

Follow on from this PR: #196
which added support for ignoring `multiline-extract-comments` from markdown
files. We only accounted for `.md` extensions and not `.markdown`, which is
also valid.

This will fix an error upstream in the readme-micro action which uses
swagger-inline to try and extract openapi operations from code.
  • Loading branch information
domharrington authored Jul 17, 2024
1 parent fc1300d commit 1fa4e39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions __tests__/__fixtures__/project-openapi/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a test README.

It should not be picked up by `swagger-inline` and throw errors because it doesn't have any docblocks.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function swaggerInline(globPatterns, providedOptions) {
});
} catch (err) {
// If the file that we failed to parse is a text file, let's just ignore it.
if (['.json', '.md', '.txt'].includes(path.extname(fileInfo.fileName))) {
if (['.json', '.md', '.markdown', '.txt'].includes(path.extname(fileInfo.fileName))) {
return Promise.resolve();
} else if (/Cannot find language definition/.test(err.message)) {
return Promise.resolve();
Expand Down

0 comments on commit 1fa4e39

Please sign in to comment.