Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt: creating a zip file with the current date (AAAA-MM-DD)

I've been looking all over for a way to name a zip file with the current date, using the "grunt-contrib-compress" plugin. Is there a way to accomplish it? I properly installed it, and set as follow:

        compress: {
         build: {
            options: {
                archive: './zipped/foo.zip',
                mode: 'zip'
            },
            files: [
                { src: 'build/**'}
            ]
         }
        }

I would like to have a zipped file named as the current date, in place of the custom name "foo":

2014-09-25.zip
like image 547
Giacomo Paita Avatar asked Sep 25 '14 08:09

Giacomo Paita


1 Answers

You can try using grunt.template.today() ...

   compress: {
     build: {
        options: {
            archive: './zipped/' + grunt.template.today('yyyy-mm-dd') + '.zip',
            mode: 'zip'
        },
        files: [
            { src: 'build/**'}
        ]
     }
    }
like image 65
JME Avatar answered Nov 11 '22 14:11

JME