Merge pull request #58 from frontrowed/flow

add an option to add a flow header
This commit is contained in:
Ido 2015-08-30 09:44:20 +03:00
commit 5995959d77
2 changed files with 9 additions and 1 deletions

View File

@ -107,6 +107,10 @@ module.exports = optionator({
alias: 'rn',
type: 'Boolean',
description: 'Renders react native templates.'
}, {
option: 'flow',
type: 'Boolean',
description: 'Add /* @flow */ to the top of the generated file'
}, {
option: 'native-target-version',
alias: 'rnv',

View File

@ -68,7 +68,8 @@ function getOptions(options) {
reactImportPath: options.native ? 'react-native' : 'react/addons',
lodashImportPath: 'lodash',
native: false,
nativeTargetVersion: reactNativeSupport.default
nativeTargetVersion: reactNativeSupport.default,
flow: options.flow
};
var finalOptions = _.defaults({}, options, defaultOptions);
@ -589,6 +590,9 @@ function convertRT(html, reportContext, options) {
return 'var ' + reqVar + " = require('" + reqPath + "');";
}).join('\n');
}
if (options.flow){
vars = '/* @flow */\n' + vars
}
var data = {body: body, injectedFunctions: '', requireNames: requireVars, requirePaths: requirePaths, vars: vars, name: options.name};
data.injectedFunctions = context.injectedFunctions.join('\n');
var code = generate(data, options);