I've just started using grunt-init. I have everything working. And I was wondering if there is a way to do conditional copy root files based on prompts which based on answers to previous prompts.
Asked
Active
Viewed 297 times
1 Answers
2
You can make use of the rename.json
file via the docs.
The prop should be the path to the file you want to copy/not copy, and the value can be a template string with a conditional. For example, let's say you had two different main.js
files, one empty and one with code you tend to re-use:
{
"app/js/main-empty.js": "{% if (empty) { %}app/js/main.js{% } %}",
"app/js/main-skeleton.js": "{% if (!empty) { %}app/js/main.js{% } %}"
}
The destpath
checks the value of the props.empty
variable from your template.js
file, copies and renames correctly.
Here is a link to a gist showing the template.js
and rename.js
for that example.

Joshua Jones
- 21
- 5