Skip to content

Commit e03d15f

Browse files
author
Yury Shapkarin
committed
refact
1 parent 7729edf commit e03d15f

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

bin/initialize.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ program
185185
},
186186
validate: function(input) {
187187
let propNames = input.split(' ');
188-
numberOfPropTypes = propNames.length;
188+
//numberOfPropTypes = propNames.length;
189189

190190
if (!checkDuplicates(propNames)) {
191191
return 'duplicate prop names';
@@ -217,25 +217,19 @@ program
217217
} else {
218218
let opts = [];
219219
let propNames = answers.propNames.split(' ');
220-
// TODO: refact props: {typed: [], notTyped: []}
221-
// and better regexp
222-
const propsWithoutTypes = propNames.filter(function(prop) {
223-
return !/:/.test(prop);
224-
});
225-
226-
const propsWithTypes = propNames.filter(function(prop) {
227-
return /:/.test(prop);
228-
});
220+
const result = {};
229221

230-
let result = {};
231-
for (prop of propsWithTypes) {
232-
const match = prop.match(/^[a-z0-9]+|\*/ig);
233-
const key = match[0] + (match[1] ? '*' : '');
234-
result[key] = prop.match(/:[a-z0-9]+/ig)[0].substring(1);
235-
};
222+
for (prop of propNames){
223+
if(/:/.test(prop)){
224+
const match = prop.match(/^[a-z0-9]+|\*/ig);
225+
const key = match[0] + (match[1] ? '*' : '');
226+
result[key] = prop.match(/:[a-z0-9]+/ig)[0].substring(1);
227+
}
228+
}
236229

237-
propNames = propsWithoutTypes;
238-
//todo: fix that
230+
propNames = propNames.filter(function(prop) {
231+
return !/:/.test(prop);
232+
});
239233
numberOfPropTypes = propNames.length;
240234

241235
for (

0 commit comments

Comments
 (0)