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

process destination path.

Open WORMSS opened this issue 11 years ago • 1 comments

There does not seem to be a way to differentiate between which file is which. All files going through process all report themselves as app/index.html which as you can guess in this situation is not helpful.

copy: {
    build4: {
        files: [{
            src: '<%= yeoman.app %>/index.html',
            dest: '_tmp/index1.html',
        }, {
            src: '<%= yeoman.app %>/index.html',
            dest: '_tmp/index2.html',
        }, {
            src: '<%= yeoman.app %>/index.html',
            dest: '_tmp/index3.html',
        }, {
            src: '<%= yeoman.app %>/index.html',
            dest: '_tmp/index4.html',
        }],
        options: {
            process : function (content, srcpath, destpath) {
                var datasource;
                switch ( destpath ) {
                    case '_tmp/index1.html' :
                        datasource = 'path to this datasource';
                        break;
                    .... the rest of them being different
                }
                return content.replace("%DataSource%", datasource);
            },
        },
    },
},

This is obviously not the end result and just an experiment of the kind of thing I need to do but more complex. I had thought about doing a copy function for each file, but that could be hundreds depending on certain situations. So not something realistic. If anyone has any help they can give? I tried putting a process on each object within files:[] but that did not work, apparently it needs to be on the root of the build option.

WORMSS avatar Sep 26 '14 07:09 WORMSS

The process function is handled by grunt itself and not by this project and although it is possible to do it in code here (see #155), it is already fixed in the grunt.file in this commit: grunt/gruntjs@2f0053f0db154f0911ff6498b4223d64dee3f76e

Unfortunately this commit is not in the stable release (0.4.5). So you must wait till 0.4.6 is stable or take the risk of using the develop version.

TurBas avatar Feb 20 '15 22:02 TurBas