0
我想要將git commit ID作爲我創建的zip文件的一部分。我試圖使用grunt-git-rev-parse
,但我沒有運氣。我的zip文件是name-.zip
而不是name-3A5BC3.zip
。我如何去獲取git commit ID到我的文件名?試圖在grunt中獲取git commit ID
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
"git-rev-parse": {
options: {
prop: 'git-revision',
number: 6
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
},
},
all: ['gruntfile.js', 'public/javascripts/**/*.js'],
},
bower: {
install: {
options: {
install: true,
copy: false
}
}
},
jade: {
compile: {
options: {
data: {
debug: false
}
},
files: {
"build/html/index.html": ["src/jade/index.jade"],
"build/html/login.html": ["src/jade/login.jade"]
}
}
},
stylus: {
compile: {
options: {
urlfunc: 'embedurl'
},
files: {
'build/css/site.css': ['src/stylus/site.styl']
}
}
},
uglify: {
options: {
mangle: false,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'build/js/<%= pkg.name %>.min.js': ['public/javascripts/**/*.js',
'bower_components/angulartics/src/angulartics.js',
'bower_components/angulartics/src/angulartics-google-analytics.js']
}
}
},
compress: {
main: {
options: {
archive: "<%= pkg.name %>-<%= grunt.config.get('git-revision') %>.zip",
mode: 'zip',
pretty: true
},
files: [
{expand: true, cwd: 'build/', src: ['**/*']}
]
}
}
});
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-git-rev-parse');
grunt.registerTask('test', ['jshint']);
grunt.registerTask('build', ['bower', 'jade', 'stylus', 'uglify']);
grunt.registerTask('pkg', ['git-rev-parse', 'compress:main']);
};