@@ -26,17 +26,12 @@ export const parser = (filePaths: Array<string>): Array<File> => {
26
26
containsComponentDef = true ;
27
27
}
28
28
29
- if (
30
- ! containsComponentDef &&
31
- file ?. match ( / @ I n p u t / g) == null &&
32
- file ?. match ( / @ O u t p u t / g) == null
33
- ) {
29
+ if ( ! containsComponentDef && file ?. match ( / @ I n p u t / g) == null && file ?. match ( / @ O u t p u t / g) == null ) {
34
30
logger . log ( "No component, Inputs or Outputs defined in this file" ) ;
35
31
continue ;
36
32
}
37
33
38
- let fileNameData : Array < string > =
39
- file ?. match ( REGEX_SELECTORS . componentSelector ) || [ ] ;
34
+ let fileNameData : Array < string > = file ?. match ( REGEX_SELECTORS . componentSelector ) || [ ] ;
40
35
if ( fileNameData . length === 0 ) {
41
36
logger . warn ( "Component tag not defined by any class." ) ;
42
37
continue ;
@@ -50,12 +45,9 @@ export const parser = (filePaths: Array<string>): Array<File> => {
50
45
let selector = "" ;
51
46
if ( containsComponentDef ) {
52
47
// match returns a string not an array
53
- let componentSelectorData : Array < string > =
54
- file ?. match ( REGEX_SELECTORS . componentHTMLselector ) || [ ] ;
48
+ let componentSelectorData : Array < string > = file ?. match ( REGEX_SELECTORS . componentHTMLselector ) || [ ] ;
55
49
if ( componentSelectorData . length === 0 ) {
56
- logger . warn (
57
- "Component doesn't define any selector but contains @Component anotation."
58
- ) ;
50
+ logger . warn ( "Component doesn't define any selector but contains @Component anotation." ) ;
59
51
continue ;
60
52
}
61
53
componentSelectorData [ 0 ] . replace ( / ( \s + ) / g, " " ) ;
@@ -66,17 +58,11 @@ export const parser = (filePaths: Array<string>): Array<File> => {
66
58
// notice we ignore the default value of the input in the regex
67
59
// Input() foo: 'type1' | 'type2'
68
60
let inputs : Array < Input > = [ ] ;
69
- let inputsData : Array < string > =
70
- file ?. match ( REGEX_SELECTORS . regularInputLiteralTypeSelector ) || [ ] ;
61
+ let inputsData : Array < string > = file ?. match ( REGEX_SELECTORS . regularInputLiteralTypeSelector ) || [ ] ;
71
62
for ( let input of inputsData ) {
72
63
logger . log ( "inputs parsed:" , inputsData ) ;
73
64
let tmp : Array < string > = input . replace ( / ( \s ) + / g, " " ) . split ( " " ) ;
74
- let type = tmp
75
- . slice ( 2 , tmp . length )
76
- . join ( )
77
- . replace ( / \" / g, "'" )
78
- . replace ( ";" , "" )
79
- . replace ( / , / g, "" ) ;
65
+ let type = tmp . slice ( 2 , tmp . length ) . join ( ) . replace ( / \" / g, "'" ) . replace ( ";" , "" ) . replace ( / , / g, "" ) ;
80
66
inputs . push ( {
81
67
inputName : tmp [ 1 ] . replace ( ":" , "" ) ,
82
68
type,
@@ -86,8 +72,7 @@ export const parser = (filePaths: Array<string>): Array<File> => {
86
72
87
73
// @Input () variableName: type; and @Input() variableName: number = 9;
88
74
inputsData = [ ] ;
89
- inputsData =
90
- file ?. match ( REGEX_SELECTORS . regularInputWithTypeSelector ) || [ ] ;
75
+ inputsData = file ?. match ( REGEX_SELECTORS . regularInputWithTypeSelector ) || [ ] ;
91
76
for ( let input of inputsData ) {
92
77
let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
93
78
inputs . push ( {
@@ -99,12 +84,10 @@ export const parser = (filePaths: Array<string>): Array<File> => {
99
84
100
85
inputsData = [ ] ;
101
86
// @Input ('inputName') varName: type; and @Input("inputName") varName: type
102
- inputsData =
103
- file ?. match ( REGEX_SELECTORS . customNameInputWithTypeSelector ) || [ ] ;
87
+ inputsData = file ?. match ( REGEX_SELECTORS . customNameInputWithTypeSelector ) || [ ] ;
104
88
for ( let input of inputsData ) {
105
89
let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
106
- const inputName = ( tmp [ 0 ] . match ( / ( ' | " ) [ a - z A - Z 0 - 9 - _ ] + ( ' | " ) / g) ||
107
- [ ] ) [ 0 ] . replace ( / ' | " / g, "" ) ;
90
+ const inputName = ( tmp [ 0 ] . match ( / ( ' | " ) [ a - z A - Z 0 - 9 - _ ] + ( ' | " ) / g) || [ ] ) [ 0 ] . replace ( / ' | " / g, "" ) ;
108
91
inputs . push ( {
109
92
inputName,
110
93
type : tmp [ 2 ] . replace ( ";" , "" ) ,
@@ -115,13 +98,10 @@ export const parser = (filePaths: Array<string>): Array<File> => {
115
98
// @Input ('inputNameC') varName = 'adv';
116
99
// @Input ("inputNameD") varName = 2354;
117
100
inputsData = [ ] ;
118
- inputsData =
119
- file ?. match ( REGEX_SELECTORS . setterInputCustomNameSelector ) || [ ] ;
101
+ inputsData = file ?. match ( REGEX_SELECTORS . setterInputCustomNameSelector ) || [ ] ;
120
102
for ( let input of inputsData ) {
121
103
let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
122
- const inputName = ( tmp [ 0 ] . match ( / ( ' | " ) [ a - z A - Z 0 - 9 - _ ] + ( ' | " ) / g) || [
123
- "" ,
124
- ] ) [ 0 ] . replace ( / ' | " / g, "" ) ;
104
+ const inputName = ( tmp [ 0 ] . match ( / ( ' | " ) [ a - z A - Z 0 - 9 - _ ] + ( ' | " ) / g) || [ "" ] ) [ 0 ] . replace ( / ' | " / g, "" ) ;
125
105
inputs . push ( {
126
106
inputName,
127
107
type : undefined ,
@@ -158,8 +138,7 @@ export const parser = (filePaths: Array<string>): Array<File> => {
158
138
159
139
//@Input () set foo(value: 'type1' | 'type2') {}
160
140
inputsData = [ ] ;
161
- inputsData =
162
- file ?. match ( REGEX_SELECTORS . setterInputLiteralTypeSelector ) || [ ] ;
141
+ inputsData = file ?. match ( REGEX_SELECTORS . setterInputLiteralTypeSelector ) || [ ] ;
163
142
for ( let input of inputsData ) {
164
143
let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
165
144
const inputName = tmp [ 2 ] . replace ( / ( \s + ) / g, "" ) . split ( "(" ) [ 0 ] ;
@@ -195,16 +174,12 @@ export const parser = (filePaths: Array<string>): Array<File> => {
195
174
196
175
let outputs : Array < Output > = [ ] ;
197
176
// only @Output () buttonClick: EventEmitter<any> = new EventEmitter(); for now
198
- let outputsData : Array < string > =
199
- file ?. match ( REGEX_SELECTORS . regularOutputSelector ) || [ ] ;
177
+ let outputsData : Array < string > = file ?. match ( REGEX_SELECTORS . regularOutputSelector ) || [ ] ;
200
178
for ( let output of outputsData ) {
201
179
let tmp : Array < string > = output . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
202
180
outputs . push ( {
203
181
outputName : tmp [ 1 ] . replace ( ":" , "" ) ,
204
- type : tmp [ 2 ]
205
- . substr ( tmp [ 2 ] . indexOf ( "<" ) , tmp [ 2 ] . indexOf ( ">" ) )
206
- . replace ( ">" , "" )
207
- . replace ( "<" , "" ) ,
182
+ type : tmp [ 2 ] . substr ( tmp [ 2 ] . indexOf ( "<" ) , tmp [ 2 ] . indexOf ( ">" ) ) . replace ( ">" , "" ) . replace ( "<" , "" ) ,
208
183
} ) ;
209
184
}
210
185
file = file . replace ( REGEX_SELECTORS . regularOutputSelector , "" ) ;
@@ -213,20 +188,13 @@ export const parser = (filePaths: Array<string>): Array<File> => {
213
188
let extendedClassPath ;
214
189
if ( file ?. match ( REGEX_SELECTORS . extendedClassSelector ) ) {
215
190
// we should see if the extended class is in tmp and if not extract the inputs defined inside
216
- let matchExtendedClass : Array < string > =
217
- file ?. match ( REGEX_SELECTORS . extendedClassSelector ) || [ ] ;
191
+ let matchExtendedClass : Array < string > = file ?. match ( REGEX_SELECTORS . extendedClassSelector ) || [ ] ;
218
192
// resolve the path of the class
219
- let extendedClass : string = matchExtendedClass [ 0 ]
220
- . replace ( / ( \s + ) / g, " " )
221
- . split ( " " ) [ 4 ] ;
193
+ let extendedClass : string = matchExtendedClass [ 0 ] . replace ( / ( \s + ) / g, " " ) . split ( " " ) [ 4 ] ;
222
194
logger . log ( "extendedClassName:" , extendedClass ) ;
223
- let matchExtendedClassPath : Array < string > =
224
- file ?. match ( REGEX_SELECTORS . extendedClassPathSelector ) || [ ] ;
195
+ let matchExtendedClassPath : Array < string > = file ?. match ( REGEX_SELECTORS . extendedClassPathSelector ) || [ ] ;
225
196
226
- extendedClassPath = pathResolver . resolve (
227
- filePath ,
228
- matchExtendedClassPath [ 0 ]
229
- ) ;
197
+ extendedClassPath = pathResolver . resolve ( filePath , matchExtendedClassPath [ 0 ] ) ;
230
198
231
199
logger . log ( "path:" , extendedClassPath ) ;
232
200
}
@@ -264,14 +232,8 @@ export const parser = (filePaths: Array<string>): Array<File> => {
264
232
if ( result [ i ] . extendedClassFilepath ) {
265
233
for ( let j = 0 ; j < tmp . length ; ++ j ) {
266
234
if ( result [ i ] . extendedClassFilepath === tmp [ j ] . fileLocation ) {
267
- result [ i ] . inputs = [
268
- ...result [ i ] . inputs ,
269
- ...( tmp [ j ] . inputs as [ ] ) ,
270
- ] as Input [ ] ;
271
- result [ i ] . outputs = [
272
- ...result [ i ] . outputs ,
273
- ...( tmp [ j ] . outputs as [ ] ) ,
274
- ] as Output [ ] ;
235
+ result [ i ] . inputs = [ ...result [ i ] . inputs , ...( tmp [ j ] . inputs as [ ] ) ] as Input [ ] ;
236
+ result [ i ] . outputs = [ ...result [ i ] . outputs , ...( tmp [ j ] . outputs as [ ] ) ] as Output [ ] ;
275
237
break ;
276
238
}
277
239
}
0 commit comments