From dc421097f06b4b4d63385561f81d346a52534dad Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Thu, 20 Aug 2015 16:07:59 -0700 Subject: [PATCH] add an option to add a flow header --- src/options.js | 4 ++++ src/reactTemplates.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/options.js b/src/options.js index d3934c4..eb5452a 100644 --- a/src/options.js +++ b/src/options.js @@ -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', diff --git a/src/reactTemplates.js b/src/reactTemplates.js index cd78bb2..7796d4c 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -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);