@@ -55,20 +55,8 @@ export const parser = (filePaths: Array<string>): Array<File> => {
55
55
logger . log ( "Selector:" , selector ) ;
56
56
}
57
57
58
- let inputs : Array < Input > = parseInputs ( file ) ;
59
-
60
- let outputs : Array < Output > = [ ] ;
61
- // only @Output () buttonClick: EventEmitter<any> = new EventEmitter(); for now
62
- let outputsData : Array < string > = file ?. match ( REGEX_SELECTORS . regularOutputSelector ) || [ ] ;
63
- for ( let output of outputsData ) {
64
- let tmp : Array < string > = output . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
65
- outputs . push ( {
66
- outputName : tmp [ 1 ] . replace ( ":" , "" ) ,
67
- type : tmp [ 2 ] . substr ( tmp [ 2 ] . indexOf ( "<" ) , tmp [ 2 ] . indexOf ( ">" ) ) . replace ( ">" , "" ) . replace ( "<" , "" ) ,
68
- } ) ;
69
- }
70
- file = file . replace ( REGEX_SELECTORS . regularOutputSelector , "" ) ;
71
- logger . log ( "Outputs detected:" , outputs ) ;
58
+ let inputs : Array < Input > = parseInputs ( file ) ,
59
+ outputs : Array < Output > = parseOutputs ( file ) ;
72
60
73
61
let extendedClassPath ;
74
62
if ( file ?. match ( REGEX_SELECTORS . extendedClassSelector ) ) {
@@ -127,6 +115,11 @@ export const parser = (filePaths: Array<string>): Array<File> => {
127
115
return result ;
128
116
} ;
129
117
118
+ /**
119
+ * @private
120
+ * @param {string } file a string where to look for input definitions
121
+ * @returns {Array<Input> } An array containing all the inputs defined in the given string
122
+ */
130
123
const parseInputs = ( file : string ) : Array < Input > => {
131
124
// notice we ignore the default value of the input in the regex
132
125
// Input() foo: 'type1' | 'type2'
@@ -246,3 +239,25 @@ const parseInputs = (file: string): Array<Input> => {
246
239
logger . log ( "Inputs detected:" , inputs ) ;
247
240
return inputs ;
248
241
} ;
242
+
243
+ /**
244
+ * @private
245
+ * @param {string } file a string where to look for output definitions
246
+ * @returns {Array<Input> } An array containing all the outputs defined in the given string
247
+ */
248
+ const parseOutputs = ( file : string ) : Array < Output > => {
249
+ let outputs : Array < Output > = [ ] ;
250
+ // only @Output () buttonClick: EventEmitter<any> = new EventEmitter(); for now
251
+ let outputsData : Array < string > = file ?. match ( REGEX_SELECTORS . regularOutputSelector ) || [ ] ;
252
+ for ( let output of outputsData ) {
253
+ let tmp : Array < string > = output . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
254
+ outputs . push ( {
255
+ outputName : tmp [ 1 ] . replace ( ":" , "" ) ,
256
+ type : tmp [ 2 ] . substr ( tmp [ 2 ] . indexOf ( "<" ) , tmp [ 2 ] . indexOf ( ">" ) ) . replace ( ">" , "" ) . replace ( "<" , "" ) ,
257
+ } ) ;
258
+ }
259
+ file = file . replace ( REGEX_SELECTORS . regularOutputSelector , "" ) ;
260
+ logger . log ( "Outputs detected:" , outputs ) ;
261
+
262
+ return outputs ;
263
+ } ;
0 commit comments