I'm doing a generator using Yeoman
I know it must be very simple, but I start using yeoman very recently and I'm not very familiar with it.
I want to get the user's input and use it to change a class name or variable
I ask the user what is the name of the class
this.controllerName = await this.prompt({
type: 'input',
name: 'controllerName',
message: `What's the name of the controller?`
})
I know how to change the file's name
this.destinationPath(`${this.controllerName.controllerName}Controller.js`)
But I don't know how to change a field inside the file. Example:
My template class
class TemplateController {
createTemplate (req, res) {
console.log('GET request')
res.json('URL WORKING!')
}
I'd like to change the class/method name for what the user answered in the prompt
class UserController {
createUser (req, res) {
console.log('GET request')
res.json('URL WORKING!')
}