add an option to add a flow header

This commit is contained in:
Greg Weber 2015-08-20 16:07:59 -07:00
parent 24db05797a
commit dc421097f0
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);
@ -588,6 +589,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);