From 1fa4e39a6ece53bbda323a9ad28f43ef40065386 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Wed, 17 Jul 2024 17:08:26 +0100 Subject: [PATCH] fix: more error handling for files that will never contain docblocks (#321) Follow on from this PR: https://github.com/readmeio/swagger-inline/pull/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. --- __tests__/__fixtures__/project-openapi/README.markdown | 3 +++ src/index.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 __tests__/__fixtures__/project-openapi/README.markdown diff --git a/__tests__/__fixtures__/project-openapi/README.markdown b/__tests__/__fixtures__/project-openapi/README.markdown new file mode 100644 index 0000000..3fd4432 --- /dev/null +++ b/__tests__/__fixtures__/project-openapi/README.markdown @@ -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. diff --git a/src/index.js b/src/index.js index 181f1df..7024a81 100644 --- a/src/index.js +++ b/src/index.js @@ -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();