generate-react-cli
Advanced tools
Comparing version
@@ -5,2 +5,9 @@ # Changelog | ||
## [7.1.0](https://github.com/arminbro/generate-react-cli/compare/v7.0.6...v7.1.0) (2022-03-15) | ||
### Features | ||
* adds dry-run flag to preview generated paths without writing files ([483aef2](https://github.com/arminbro/generate-react-cli/commit/483aef285a356bb02727d3c512d2e03e22b6493a)) | ||
### [7.0.6](https://github.com/arminbro/generate-react-cli/compare/v7.0.5...v7.0.6) (2022-02-21) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "generate-react-cli", | ||
"version": "7.0.6", | ||
"version": "7.1.0", | ||
"description": "A simple React CLI to generate components instantly and more.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/arminbro/generate-react-cli", |
@@ -154,2 +154,10 @@ # Generate React CLI | ||
</tr> | ||
<tr> | ||
<td width="20%"><b>--dry-run</b></td> | ||
<td width="60%"> | ||
Show what will be generated without writing to disk | ||
</td> | ||
<td width="20%">Boolean</td> | ||
<td width="20%"><code>false<code></td> | ||
</tr> | ||
</table> | ||
@@ -156,0 +164,0 @@ |
@@ -37,2 +37,4 @@ const { upperFirst } = require('lodash'); | ||
componentCommand.option('--dry-run', 'Show what will be generated without writing to disk') | ||
// Component command action. | ||
@@ -39,0 +41,0 @@ |
@@ -358,35 +358,37 @@ const chalk = require('chalk'); | ||
try { | ||
outputFileSync(componentPath, template); | ||
if (!cmd.dryRun) { | ||
outputFileSync(componentPath, template); | ||
replace({ | ||
regex: 'TemplateName', | ||
replacement: componentName, | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'TemplateName', | ||
replacement: componentName, | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'templateName', | ||
replacement: camelCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'templateName', | ||
replacement: camelCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'template-name', | ||
replacement: kebabCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'template-name', | ||
replacement: kebabCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'template_name', | ||
replacement: snakeCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
replace({ | ||
regex: 'template_name', | ||
replacement: snakeCase(componentName), | ||
paths: [componentPath], | ||
recursive: false, | ||
silent: true, | ||
}); | ||
} | ||
@@ -401,2 +403,7 @@ console.log(chalk.green(`${filename} was successfully created at ${componentPath}`)); | ||
}); | ||
if (cmd.dryRun) { | ||
console.log() | ||
console.log(chalk.yellow(`NOTE: The "dry-run" flag means no changes were made.`)) | ||
} | ||
} | ||
@@ -403,0 +410,0 @@ |
51872
1.64%643
1.1%372
2.2%