grunt-init template exclude files from init.filesToCopy(props)

56 Views Asked by At

I've just started using grunt-init. I have everything working. And I was wondering if there is a way to exclude files from copying based on answers to prompts.

'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();
    });
};

rename.js file

{
  "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 implementation didn't help also

1

There are 1 best solutions below

0
narainsagar On BEST ANSWER

@francesca I think your filename should be rename.json instead of rename.js.

The template directory structure needs to be like this: -> SampleTemplate -> root - rename.json - template.js

Ref:

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

OR

Read the official documentation for more

Cheers!