【问题标题】:Grunt: creating a zip file with the current date (AAAA-MM-DD)Grunt:使用当前日期创建一个 zip 文件 (AAAA-MM-DD)
【发布时间】:2014-09-25 08:50:42
【问题描述】:

我一直在寻找一种使用“grunt-contrib-compress”插件来用当前日期命名 zip 文件的方法。有没有办法实现它?我正确安装了它,并设置如下:

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

我想要一个以当前日期命名的压缩文件来代替自定义名称“foo”:

2014-09-25.zip

【问题讨论】:

    标签: javascript plugins gruntjs grunt-contrib-compress


    【解决方案1】:

    您可以尝试使用grunt.template.today() ...

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

    【讨论】:

    • archive: 'dist/archive' + grunt.template.today('yyyy-mm-dd HH.MM.ss') + '.zip' - 如果你也想要时间
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多