Friday, 17 March 2017

Grunt Rename Works but Append the File Multiple Times

I used the rename function into grunt process html to rename all the files with *_test.html only to *.html in the same folder

processhtml: {
            dist: {
                options: {
                    process: true,
                    templateSettings: {
                        interpolate: //g
                    }
                },
                files: [{
                    expand: true,
                    cwd: 'dist/web',
                    src: ['**/*.html'],
                    dest: 'dist/web/',
                    ext: '_test.html',
                    rename: function (dest, src){
                        return dest + src.replace('_test.html', '.html');
                    }
                }, ],
            }
        },

Renaming files work perfectly, but if I run the grunt process html once more, the files is not overwrite, instead the content of index_test.html is appended to the index.html such:

<html>
   <head></head>
   <body></body>
</html>

is becoming double like:

<html>
   <head></head>
   <body></body>
</html>
<html>
   <head></head>
   <body></body>
</html>

and so on everytime I run the grunt process html

Any suggestions? Thanks!



via Ray

No comments:

Post a Comment