mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
add dry run option
This commit is contained in:
parent
48cb50143d
commit
a65eff45c4
@ -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 = {
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user