Search code examples
yeomanyeoman-generator

Copy all files but change the name of some automatically in yeoman


I am trying to create a yeoman generator where I have to copy from templatePath to destinationPath some files and folders, but I would want to have some of this files with a variable that yeoman could change by one of the user's inputs.

like: "<%=name%>-plugin.php" -> "hello-plugin.php"

I saw some references that this can be done but I can't find how.

I am doing right now:

//Copy the configuration files
    app: function () {
      this.fs.copyTpl(
        this.templatePath('**'),
        this.destinationPath(), 
        {
          name: this.props.pluginName,
          name_function: this.props.pluginName.replace('-', '_'),
          name_class: this.props.className,
          description: this.props.pluginDescription
        }
      );
    }

I thought that with that code my <%=name%> would magically changed on copyTpl but it doesn't work


Solution

  • This is not possible anymore. The feature was bloated and was removed at some point in 2015.

    For now, just rename the file:

    this.fs.copy('name.js', 'new-name.js')