add an option to add a flow header
This commit is contained in:
parent
24db05797a
commit
dc421097f0
|
@ -107,6 +107,10 @@ module.exports = optionator({
|
||||||
alias: 'rn',
|
alias: 'rn',
|
||||||
type: 'Boolean',
|
type: 'Boolean',
|
||||||
description: 'Renders react native templates.'
|
description: 'Renders react native templates.'
|
||||||
|
}, {
|
||||||
|
option: 'flow',
|
||||||
|
type: 'Boolean',
|
||||||
|
description: 'Add /* @flow */ to the top of the generated file'
|
||||||
}, {
|
}, {
|
||||||
option: 'native-target-version',
|
option: 'native-target-version',
|
||||||
alias: 'rnv',
|
alias: 'rnv',
|
||||||
|
|
|
@ -68,7 +68,8 @@ function getOptions(options) {
|
||||||
reactImportPath: options.native ? 'react-native' : 'react/addons',
|
reactImportPath: options.native ? 'react-native' : 'react/addons',
|
||||||
lodashImportPath: 'lodash',
|
lodashImportPath: 'lodash',
|
||||||
native: false,
|
native: false,
|
||||||
nativeTargetVersion: reactNativeSupport.default
|
nativeTargetVersion: reactNativeSupport.default,
|
||||||
|
flow: options.flow
|
||||||
};
|
};
|
||||||
|
|
||||||
var finalOptions = _.defaults({}, options, defaultOptions);
|
var finalOptions = _.defaults({}, options, defaultOptions);
|
||||||
|
@ -588,6 +589,9 @@ function convertRT(html, reportContext, options) {
|
||||||
return 'var ' + reqVar + " = require('" + reqPath + "');";
|
return 'var ' + reqVar + " = require('" + reqPath + "');";
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
}
|
}
|
||||||
|
if (options.flow){
|
||||||
|
vars = '/* @flow */\n' + vars
|
||||||
|
}
|
||||||
var data = {body: body, injectedFunctions: '', requireNames: requireVars, requirePaths: requirePaths, vars: vars, name: options.name};
|
var data = {body: body, injectedFunctions: '', requireNames: requireVars, requirePaths: requirePaths, vars: vars, name: options.name};
|
||||||
data.injectedFunctions = context.injectedFunctions.join('\n');
|
data.injectedFunctions = context.injectedFunctions.join('\n');
|
||||||
var code = generate(data, options);
|
var code = generate(data, options);
|
||||||
|
|
Loading…
Reference in New Issue