Wednesday, 7 August 2013

Is there any way to do prompt text replacement in a filename with Yeoman generator?

Is there any way to do prompt text replacement in a filename with Yeoman
generator?

I'm creating a custom generator and I'd like to not only do prompt
replacement in the files themselves but also in the filenames.
I have prompts defined as:
var prompts = [{
name: 'companyName',
message: 'What is your company name?',
default: 'MyCompany'
}];
I'm also copying an entire folder structure located in /templates/root to
my project folder with:
this.directory('root','.');
which will replace occurrences of <%= companyName %> with 'MyCompany' in
any of those files. This all works fine so far.
Here is what I'd like to also do.
I'd like to also replace occurrences of 'companyName' or '$companyName$'
in the filenames themselves so that if I have a file named
/templates/root/$companyName$.Something.proj I'll get a file in my project
folder named 'MyCompany.Something.proj'

No comments:

Post a Comment