Skip to content

Commit 8de0d44

Browse files
author
Yury Shapkarin
committed
pre name:type
1 parent d9214ad commit 8de0d44

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

bin/initialize.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ 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+
});
229+
230+
let result = {};
231+
for (prop of propsWithTypes) {
232+
result[prop.match(/^[a-z0-9]+/ig)[0]] = prop.match(/:[a-z0-9]+/ig)[0].substring(1);
233+
};
234+
235+
propNames = propsWithoutTypes;
236+
//todo: fix that
237+
numberOfPropTypes = propNames.length;
220238

221239
for (
222240
let count = 0;
@@ -241,11 +259,12 @@ program
241259
opts.push(propTypeChoice);
242260
}
243261
inquirer.prompt(opts).then(function(answersInner) {
262+
const _answersInner = {...result, ...answersInner};
244263
generate.createComponent(
245264
modulename,
246265
name,
247266
answers,
248-
answersInner,
267+
_answersInner,
249268
options.file,
250269
function(status) {
251270
if (status) {

0 commit comments

Comments
 (0)