list version and expose convertTemplate
This commit is contained in:
parent
6662bda1e6
commit
21271eefa4
20
src/cli.js
20
src/cli.js
|
@ -12,6 +12,8 @@ var shell = require('./shell');
|
|||
var pkg = require('../package.json');
|
||||
//var defaultOptions = {commonJS: false, force: false, json: false};
|
||||
var options = require('./options');
|
||||
var reactDOMSupport = require('./reactDOMSupport');
|
||||
var reactTemplates = require('./reactTemplates');
|
||||
|
||||
function executeOptions(currentOptions) {
|
||||
var ret = 0;
|
||||
|
@ -26,6 +28,8 @@ function executeOptions(currentOptions) {
|
|||
} else {
|
||||
console.log(options.generateHelp());
|
||||
}
|
||||
} else if (currentOptions.listTargetVersion) {
|
||||
printVersions(currentOptions);
|
||||
} else if (!files.length) {
|
||||
console.log(options.generateHelp());
|
||||
} else {
|
||||
|
@ -35,6 +39,15 @@ function executeOptions(currentOptions) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
function printVersions(currentOptions) {
|
||||
var ret = Object.keys(reactDOMSupport);
|
||||
if (currentOptions.format === 'json') {
|
||||
console.log(JSON.stringify(ret, undefined, 2));
|
||||
} else {
|
||||
console.log(ret.join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} currentOptions
|
||||
* @param {string} filename file name to process
|
||||
|
@ -83,4 +96,9 @@ function execute(args) {
|
|||
return executeOptions(currentOptions);
|
||||
}
|
||||
|
||||
module.exports = {execute: execute, executeOptions: executeOptions, handleSingleFile: handleSingleFile};
|
||||
module.exports = {
|
||||
execute: execute,
|
||||
executeOptions: executeOptions,
|
||||
handleSingleFile: handleSingleFile,
|
||||
convertTemplateToReact: reactTemplates.convertTemplateToReact
|
||||
};
|
|
@ -75,8 +75,13 @@ module.exports = optionator({
|
|||
option: 'target-version',
|
||||
alias: 't',
|
||||
type: 'String',
|
||||
default: '0.12.1',
|
||||
default: '0.12.2',
|
||||
description: 'React version to generate code for (' + Object.keys(reactDOMSupport).join(', ') + ')'
|
||||
}, {
|
||||
option: 'list-target-version',
|
||||
type: 'Boolean',
|
||||
default: 'false',
|
||||
description: 'Show list of target versions'
|
||||
}, {
|
||||
option: 'version',
|
||||
alias: 'v',
|
||||
|
|
Loading…
Reference in New Issue