@@ -4,7 +4,7 @@ const path = require("path");
4
4
import { File , Input , Output } from "./shared/IFile" ;
5
5
import * as logger from "./shared/logger" ;
6
6
7
- //TODO: Test in in other OS (github actions)
7
+ // TODO: Test in in other OS (github actions)
8
8
// TODO: Read files synchronously
9
9
export const parser = ( filePaths : Array < string > ) : Array < File > => {
10
10
let result : Array < File > = [ ] ;
@@ -54,17 +54,10 @@ export const parser = (filePaths: Array<string>): Array<File> => {
54
54
continue ;
55
55
}
56
56
componentSelectorData [ 0 ] . replace ( / ( \s + ) / g, " " ) ;
57
- selector = componentSelectorData [ 0 ]
58
- . split ( " " ) [ 1 ]
59
- . replace ( / ( ' | " ) / g, "" ) ;
57
+ selector = componentSelectorData [ 0 ] . split ( " " ) [ 1 ] . replace ( / ( ' | " ) / g, "" ) ;
60
58
logger . log ( "Selector:" , selector ) ;
61
59
}
62
60
63
- // TODO: @Input () set foo(value: type) {};
64
-
65
- // input literal type
66
- // @Input () variableName: 'type1' | 'type2' | 'type3'; and
67
- // @Input () variableName: 'type1' | 'type2' | 'type3' = 'type1';
68
61
// notice we ignore the default value of the input in the regex
69
62
let inputs : Array < Input > = [ ] ;
70
63
let inputsData : Array < string > =
@@ -136,6 +129,57 @@ export const parser = (filePaths: Array<string>): Array<File> => {
136
129
} ) ;
137
130
}
138
131
132
+ //@Input () set foo(value) {}
133
+ inputsData = [ ] ;
134
+ inputsData =
135
+ file ?. match (
136
+ / @ I n p u t \( \) ( \s + ) s e t ( \s + ) [ A - Z a - z 0 - 9 ] + \( [ A - Z a - z 0 - 9 ] + \) ( \s + ) / g
137
+ ) || [ ] ;
138
+ for ( let input of inputsData ) {
139
+ let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
140
+ const inputName = tmp [ 2 ] . replace ( / ( \s + ) / g, "" ) . split ( "(" ) [ 0 ] ;
141
+ inputs . push ( {
142
+ inputName,
143
+ type : undefined ,
144
+ } ) ;
145
+ }
146
+
147
+ //@Input () set foo(value: type) {}
148
+ inputsData = [ ] ;
149
+ inputsData =
150
+ file ?. match (
151
+ / @ I n p u t \( \) ( \s + ) s e t ( \s + ) [ A - Z a - z 0 - 9 ] + \( [ A - Z a - z 0 - 9 ] + : ( \s + ) [ A - Z a - z 0 - 9 ] + \) ( \s + ) / g
152
+ ) || [ ] ;
153
+ for ( let input of inputsData ) {
154
+ let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
155
+ const inputName = tmp [ 2 ] . replace ( / ( \s + ) / g, "" ) . split ( "(" ) [ 0 ] ;
156
+ const type = tmp [ 3 ] . replace ( / ( \s + ) / g, "" ) . split ( ")" ) [ 0 ] ;
157
+ inputs . push ( {
158
+ inputName,
159
+ type,
160
+ } ) ;
161
+ }
162
+
163
+ //@Input () set foo(value: type) {}
164
+ inputsData = [ ] ;
165
+ inputsData =
166
+ file ?. match (
167
+ / @ I n p u t \( \) ( \s + ) s e t ( \s + ) [ A - Z a - z 0 - 9 ] + \( [ A - Z a - z 0 - 9 ] + : ( ( \s + ) ( ' | " ) [ A - Z a - z 0 - 9 ] + ( ' | " ) ( \s + ) \| ) + ( \s ) ( ' | " ) [ A - Z a - z 0 - 9 ] + ( ' | " ) \) / g
168
+ ) || [ ] ;
169
+ for ( let input of inputsData ) {
170
+ let tmp : Array < string > = input . replace ( / ( \s + ) / g, " " ) . split ( " " ) ;
171
+ const inputName = tmp [ 2 ] . replace ( / ( \s + ) / g, "" ) . split ( "(" ) [ 0 ] ;
172
+ const type = tmp
173
+ . slice ( 3 , tmp . length )
174
+ . join ( )
175
+ . replace ( / ' | " | \) / g, "" )
176
+ . replace ( / , / g, " " ) ;
177
+ inputs . push ( {
178
+ inputName,
179
+ type,
180
+ } ) ;
181
+ }
182
+
139
183
// @Input () variableName; and @Input() variableName. Also for now we will parse
140
184
// in this part of the code @Input () variableName = value and @Input() variableName = value;
141
185
inputsData = [ ] ;
0 commit comments