Rename a variable / class with Yeoman

0

Get Prompt data and use it in the templates code

I'm starting to use Yeoman and I have a question

I ask the user the name of a class through the Prompt

this.controllerName = await this.prompt({
        type: 'input',
        name: 'controllerName',
        message: 'What's the name of the controller?'
      })

I can change the file name by doing this

this.destinationPath('${this.controllerName.controllerName}Controller.js')

But I do not know how to change the name of the class or some text inside the file that I use as a template. For example: What is the name of the controller? User Home My template class

class TemplateController {
  getTest (req, res) {
    console.log('GET request')
    res.json('URL WORKING!')
  }

I wanted to change the class so

class UserController {
  getTest (req, res) {
    console.log('GET request')
    res.json('URL WORKING!')
  }
    
asked by anonymous 18.12.2018 / 17:23

0 answers