最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

        press: {
         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

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

        press: {
         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
Share Improve this question edited Sep 25, 2014 at 12:21 Giao Paita asked Sep 25, 2014 at 8:50 Giao PaitaGiao Paita 1,4192 gold badges12 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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

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

评论列表(0)

  1. 暂无评论