1
0
mirror of https://github.com/bobwen-dev/react-templates synced 2025-04-12 00:56:39 +02:00

Add cli options for react/lodash import paths

Add in options if user wants to specify different paths to lodash or react in their application.
This commit is contained in:
Suby Raman 2015-07-08 10:12:44 -04:00
parent cee215c081
commit 691e008c3e
2 changed files with 19 additions and 1 deletions

View File

@ -91,5 +91,15 @@ module.exports = optionator({
alias: 'k',
type: 'Boolean',
description: 'Show stack trace on errors.'
}, {
option: 'react-import-path',
default: 'react/addons',
type: 'String',
description: 'Dependency path for importing React.'
}, {
option: 'lodash-import-path',
default: 'lodash',
type: 'String',
description: 'Dependency path for importing lodash.'
}]
});

View File

@ -438,7 +438,15 @@ function convertTemplateToReact(html, options) {
function convertRT(html, reportContext, options) {
var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true});
options = _.defaults({}, options, defaultOptions);
var defines = options.defines ? _.clone(options.defines) : {'react/addons': 'React', lodash: '_'};
var reactPath = options.reactImportPath || 'react/addons';
var lodashPath = options.lodashImportPath || 'lodash';
var defaultDefines = {};
defaultDefines[reactPath] = 'react';
defaultDefines[lodashPath] = 'lodash';
var defines = options.defines ? _.clone(options.defines) : defaultDefines;
var context = defaultContext(html, options);
validate(options, context, reportContext, rootNode.root()[0]);
var rootTags = _.filter(rootNode.root()[0].children, {type: 'tag'});