【问题标题】:grunt-init template exclude files from init.filesToCopy(props)grunt-init 模板从 init.filesToCopy(props) 中排除文件
【发布时间】:2016-07-02 17:21:27
【问题描述】:

我刚刚开始使用 grunt-init。我有一切工作。我想知道是否有办法根据提示的答案从复制中排除文件。

'use strict';

exports.description = 'Create module';

exports.warnOn = '*';

exports.template = function(grunt, init, done){

    init.process([
        init.prompt('name'),
        {
            name: 'service',
            message: 'Do you need service?',
            default: 'Y/n',
            warning: ''
        },
        {
            name: 'collection',
            message: 'Do you need collection?',
            default: 'Y/n',
            warning: ''
        }
    ], function(err, props){

        var files = init.filesToCopy(props);

        init.copyAndProcess(files, props);

        done();
    });
};

重命名.js 文件

{
  "bootstrap-module/src/bootstrap-module/bootstrap.collection.js"     : "{%= name %}-module/src/{%= name %}-module/{%= name %}.collection.js",
  "bootstrap-module/src/bootstrap-module/bootstrap.controller.js"     : "{%= name %}-module/src/{%= name %}-module/{%= name %}.controller.js",
  "bootstrap-module/src/bootstrap-module/bootstrap.model.js"          : "{%= name %}-module/src/{%= name %}-module/{%= name %}.model.js",
  "bootstrap-module/src/bootstrap-module/bootstrap.service.js"        : "{%= name %}-module/src/{%= name %}-module/{%= name %}.service.js",
  "bootstrap-module/src/bootstrap-module/bootstrap.view.js"           : "{%= name %}-module/src/{%= name %}-module/{%= name %}.view.js",
}

This 实施也没有帮助

【问题讨论】:

    标签: templates gruntjs copy rename grunt-init


    【解决方案1】:

    @francesca 我认为你的文件名应该是rename.json 而不是rename.js

    模板目录结构需要是这样的: -> SampleTemplate -> root - rename.json - template.js

    参考:

    Read this William Walker's - great blog post from here

    Read the official documentation for more

    干杯!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多