File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ const parseFile = (
2929
3030 if ( parseCodeCrumbs ) {
3131 const codecrumbsList = codecrumbsParser . getCrumbs ( code , itemPath ) ;
32- // console.log(codecrumbsList)
3332 if ( codecrumbsList . length ) {
3433 item . fileCode = code ;
3534 item . children = codecrumbsList ;
Original file line number Diff line number Diff line change 11const lineNumber = require ( 'line-number' ) ;
2- const isUndefined = require ( 'lodash/isUndefined ' ) ;
2+ const compact = require ( 'lodash/compact ' ) ;
33const { CC_NODE_TYPE , NO_TRAIL_FLOW } = require ( '../../../shared-constants' ) ;
44
55const CRUMB_REGEX = / c c | c o d e c r u m b / ;
@@ -58,17 +58,22 @@ const setupGetCommentsFromCode = regex => fileCode => {
5858 return [ ] ;
5959 }
6060
61- const result = regex . exec ( fileCode ) || [ ] ;
61+ const result = compact ( regex . exec ( fileCode ) ) || [ ] ;
6262
6363 return result . reduce ( ( comments , value ) => {
64- if ( isUndefined ( value ) ) {
65- return comments ;
66- }
67-
6864 const matchLineNumber = lineNumber ( fileCode , regex ) ;
69- const nodeLines = [ matchLineNumber , matchLineNumber ] ;
7065
71- return [ ...comments , { value, nodeLines } ] ;
66+ const parseRes = matchLineNumber . filter ( ( val ) => val . match == value ) [ 0 ]
67+
68+ if ( parseRes ) {
69+ const number = parseRes [ "number" ]
70+
71+ const nodeLines = [ 1 , 1 ] ;
72+
73+ return [ ...comments , { value, nodeLines } ] ;
74+ } else {
75+ return comments ;
76+ }
7277
7378 } , [ ] ) ;
7479} ;
You can’t perform that action at this time.
0 commit comments