复制所有文件,但在 yeoman 中自动更改某些文件的名称 [英] Copy all files but change the name of some automatically in yeoman

查看:24
本文介绍了复制所有文件,但在 yeoman 中自动更改某些文件的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 yeoman 生成器,我必须在其中将一些文件和文件夹从 templatePath 复制到 destinationPath,但我希望其中一些文件带有一个变量,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"

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

我看到一些参考资料表明可以这样做,但我找不到方法.

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

我现在正在做:

//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
        }
      );
    }

我认为使用该代码我的 <%=name%> 会在 copyTpl 上神奇地改变,但它不起作用

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

推荐答案

这已经不可能了.该功能过于臃肿,并在 2015 年的某个时候被删除.

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')

这篇关于复制所有文件,但在 yeoman 中自动更改某些文件的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆