list version and expose convertTemplate

This commit is contained in:
ido 2015-01-19 10:38:39 +02:00
parent 6662bda1e6
commit 21271eefa4
2 changed files with 25 additions and 2 deletions

View File

@ -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
};

View File

@ -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',