add dry run option

This commit is contained in:
ido 2014-12-10 14:13:16 +02:00
parent 48cb50143d
commit a65eff45c4
2 changed files with 10 additions and 3 deletions

View File

@ -7,7 +7,7 @@ var convertTemplateToReact = reactTemplates.convertTemplateToReact;
/**
* @param {string} source
* @param {{commonJS:boolean}?} options
* @param {{commonJS:boolean, dryRun:boolean}?} options
* @param {string} target
* @param {CONTEXT} context
*/
@ -29,7 +29,9 @@ function convertFile(source, target, options, context) {
throw new Error('invalid file, missing header');
}
var js = convertTemplateToReact(html, options);
fs.writeFileSync(target, js);
if (!options.dryRun) {
fs.writeFileSync(target, js);
}
}
module.exports = {

View File

@ -46,6 +46,12 @@ module.exports = optionator({
default: 'false',
type: 'Boolean',
description: 'Use Common JS output.'
}, {
option: 'dry-run',
alias: 'd',
default: 'false',
type: 'Boolean',
description: 'Run compilation without creating an output file, used to check if the file is valid'
}, {
option: 'force',
alias: 'r',
@ -64,7 +70,6 @@ module.exports = optionator({
alias: 't',
type: 'String',
default: '0.12.1',
//enum: ['stylish', 'json'],
description: 'React version to generate code for (' + Object.keys(reactDOMSupport).join(', ') + ')'
}, {
option: 'version',