Repository: BRIKEV/express-jsdoc-swagger (js)

Issue:
[BUG] the generic filesPattern: './**/*.js' don't work
**Describe the bug**
As specified in the doc, I would like to be able to use a generic filesPattern. Using filesPattern: './**/*.js', it's not work. However, if I specify the "./app.js" file, the route is well documented.

**To Reproduce**
My app.js:
```
const express = require('express');
const expressJSDocSwagger = require('express-jsdoc-swagger');

const options = {
  info: {
    version: '1.0.0',
    title: 'Albums store',
    license: {
      name: 'MIT'
    }
  },
  security: {
    BasicAuth: {
      type: 'http',
      scheme: 'basic'
    }
  },
  baseDir: __dirname,
  filesPattern: './**/*.js',
  swaggerUIPath: '/api-docs',
  exposeSwaggerUI: true,
  exposeApiDocs: true,
  apiDocsPath: '/v3/api-docs',
  notRequiredAsNullable: false,
  swaggerUiOptions: {},
};

const app = express();
const PORT = 3000;

expressJSDocSwagger(app)(options);

/**
 * GET /api/v1
 * @tags Book
 * @summary This is the summary of the endpoint
 * @return {object} 200 - success response
 */
app.get('/api/v1', (req, res) => res.json({
  success: true,
}));

app.listen(PORT, () => console.log('Example app listening at http://localhost:${PORT}'));
```

**Screenshots**
With filesPattern: './**/*.js'
![image](https://user-images.githubusercontent.com/90182489/132188060-efbf8907-49ea-4ea5-8d3b-99f66e3e5f33.png)

With filesPattern: './app.js'
![image](https://user-images.githubusercontent.com/90182489/132187689-262aee97-a3dd-48e7-b9d0-7e3d00a60e2a.png)

**Desktop (please complete the following information):**
 - OS: Windows
 - Version 10



Pull request:
Fix/files pattern bug
### What kind of change does this PR introduce? (check at least one)
 - [X] Bugfix

### Description:
This PR fixes an error in our get comments regex when we have to read files with patterns like these ones `./*` `./*.*`.

This closes #184 


Patch:
diff --git a/consumers/utils/getComments.js b/consumers/utils/getComments.js
index a2d9668..0a40c4c 100644
--- a/consumers/utils/getComments.js
+++ b/consumers/utils/getComments.js
@@ -1,4 +1,4 @@
-const COMMENTS_PATTERN = /((\/\*+[\s\S]*?\*\/)|(\/\*+.*\*\/)|^\/\/.*?[\r\n])[\r\n]*/gm;
+const COMMENTS_PATTERN = /((\/\*\*+[\s\S]*?\*\/)|(\/\*+.*\*\/)|^\/\/.*?[\r\n])[\r\n]*/gm;
 const BREAK_LINE = /\n/g;
 
 const getComments = text => {


Test patch:
diff --git a/test/consumers/getOnlyComments/index.test.js b/test/consumers/getOnlyComments/index.test.js
index b833ec9..e6e62e7 100644
--- a/test/consumers/getOnlyComments/index.test.js
+++ b/test/consumers/getOnlyComments/index.test.js
@@ -74,6 +74,26 @@ describe('get only comments consumer method', () => {
     expect(result).toEqual(expected);
   });
 
+  it('should return only the JSdoc comment when we add a regex in the file pattern', () => {
+    const input = [`
+    const pattern = './*.js';
+    /**
+     * @param  {[type]}
+     * @param  {[type]}
+     * @return {[type]}
+     */
+
+    `];
+    const expected = [`/**
+     * @param  {[type]}
+     * @param  {[type]}
+     * @return {[type]}
+     */`];
+    const result = getOnlyComments(input);
+    expect(result).toHaveLength(1);
+    expect(result).toEqual(expected);
+  });
+
   it('should return multiline and JSdoc comment', () => {
     const input = [`
     /* this is a comment */