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

1.3k views Asked by At

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
1

There are 1 answers

1
JME On BEST ANSWER

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

   compress: {
     build: {
        options: {
            archive: './zipped/' + grunt.template.today('yyyy-mm-dd') + '.zip',
            mode: 'zip'
        },
        files: [
            { src: 'build/**'}
        ]
     }
    }