Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/files pattern bug #185

Merged
merged 3 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion consumers/utils/getComments.js
Original file line number Diff line number Diff line change
@@ -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 => {
Expand Down
20 changes: 20 additions & 0 deletions test/consumers/getOnlyComments/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down