1
1
const extractComments = require ( 'multilang-extract-comments' ) ;
2
2
const jsYaml = require ( 'js-yaml' ) ;
3
3
4
- function pushLine ( array , line ) {
5
- if ( line . trim ( ) ) {
6
- array . push ( line ) ;
7
- return true ;
8
- }
9
- return false ;
10
- }
11
-
12
4
function loadYamlWithPrettyErrors ( prettyObject , yamlLines ) {
13
5
try {
14
6
return jsYaml . load ( yamlLines . join ( '\n' ) . replace ( / \t / g, ' ' ) ) ;
@@ -85,12 +77,12 @@ class Extractor {
85
77
let route = null ;
86
78
let scopeMatched = false ;
87
79
88
- lines . some ( line => {
80
+ lines . forEach ( line => {
89
81
if ( route ) {
90
82
if ( options && options . scope ) {
91
83
if ( line . trim ( ) . indexOf ( 'scope:' ) === 0 && line . indexOf ( options . scope ) >= 0 ) {
92
84
scopeMatched = true ;
93
- return false ;
85
+ return ;
94
86
}
95
87
} else {
96
88
scopeMatched = true ;
@@ -100,16 +92,14 @@ class Extractor {
100
92
// Only return false here if this line is an explicit `scope: {string}` property and not perhaps a `scope`
101
93
// property within a request body, parameter, or response schema.
102
94
if ( line . trim ( ) . match ( / s c o p e : ( .* ) / ) ) {
103
- return false ;
95
+ return ;
104
96
}
105
97
}
106
98
107
- pushLine ( yamlLines , line ) ;
108
- // eslint-disable-next-line consistent-return
99
+ yamlLines . push ( line ) ;
109
100
return ;
110
101
}
111
102
route = route || line . match ( this . ROUTE_REGEX ) ;
112
- return false ;
113
103
} ) ;
114
104
115
105
if ( ! scopeMatched ) {
@@ -138,7 +128,7 @@ class Extractor {
138
128
if ( line . trim ( ) . indexOf ( 'scope:' ) === 0 ) {
139
129
return ;
140
130
}
141
- pushLine ( yamlLines , line ) ;
131
+ yamlLines . push ( line ) ;
142
132
return ;
143
133
}
144
134
route = route || line . match ( this . SCHEMA_REGEX ) ;
0 commit comments