grunt-pot icon indicating copy to clipboard operation
grunt-pot copied to clipboard

Make it true multitask

Open luiz-brandao opened this issue 9 years ago • 2 comments

This task doesn't seem to be a multitask. I'm new to Grunt but it seems Grunt sends different parameters when you have multiple tasks setup. For it to work properly as a multitask, the code at pot.js:87 should be changed to something like this:

    this.files[0].src.forEach(function(file) {
        if( !grunt.file.isDir( file ) ){
            inputFiles +=  " " + file;
        }
    });

If this alteration is made, the setup should change to something similar to the following :

pot: {
    first_task: {
        options: {
            text_domain: text_domain,
            dest: 'build/languages/',
            keywords: ['gettext', '__', '_e']
        },
        files: {
            src: ['build/**'],
            expand: true
        }
    }
}

luiz-brandao avatar Apr 01 '15 04:04 luiz-brandao

You're right, although defined as a multi-task you will get an error if you use it as such. Using it as follows should work though:

pot: {
        options: {
            text_domain: text_domain,
            dest: 'build/languages/',
            keywords: ['gettext', '__', '_e']
        },
        files: {
            src: ['build/**'],
            expand: true
        }
}

I haven't had time to investigate what the actual bug is, but the proposed fix seems odd for two reasons:

  1. The current line does follow the API documentation: http://gruntjs.com/api/inside-tasks#this.files
  2. The fix seems to suggest looping through this.files[0] - what's so special about that index? My concern is that if you had multiple tasks then actually you'll always be using the files from the first (this is just speculative thinking). Have you tried the fix with multiple tasks?

In short, yes there's a bug, but I'm not sure if that's where it is :)

stephenharris avatar Apr 01 '15 14:04 stephenharris

Yeah, it does look weird but that's where to problem was. Maybe my fix is not the ideal fix, but it works. I analyzed the data passed by Grunt and the files array was different from what it was before when using the multi-task configuration. I will see if I can pinpoint why.

luiz-brandao avatar Apr 01 '15 20:04 luiz-brandao