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:
parent
cee215c081
commit
691e008c3e
@ -91,5 +91,15 @@ module.exports = optionator({
|
|||||||
alias: 'k',
|
alias: 'k',
|
||||||
type: 'Boolean',
|
type: 'Boolean',
|
||||||
description: 'Show stack trace on errors.'
|
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.'
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -438,7 +438,15 @@ function convertTemplateToReact(html, options) {
|
|||||||
function convertRT(html, reportContext, options) {
|
function convertRT(html, reportContext, options) {
|
||||||
var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true});
|
var rootNode = cheerio.load(html, {lowerCaseTags: false, lowerCaseAttributeNames: false, xmlMode: true, withStartIndices: true});
|
||||||
options = _.defaults({}, options, defaultOptions);
|
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);
|
var context = defaultContext(html, options);
|
||||||
validate(options, context, reportContext, rootNode.root()[0]);
|
validate(options, context, reportContext, rootNode.root()[0]);
|
||||||
var rootTags = _.filter(rootNode.root()[0].children, {type: 'tag'});
|
var rootTags = _.filter(rootNode.root()[0].children, {type: 'tag'});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user