作爲我的grunt:build命令的一部分,我運行一個shell任務,構建我的jekyll站點,提交項目並將其推送到github。唯一的問題是提交消息。我很樂意能夠調用grunt:build並且傳遞一個字符串,這將成爲我的提交信息。但我不確定如何做到這一點。有什麼想法嗎?你如何將一個參數傳遞給一個咕嚕的任務?
這裏是我的Gruntfile的相關部分:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
dev: {
command: 'jekyll build'
},
build: {
command: [
'jekyll build',
'git commit -am "test commit"',
'git push origin master'
].join('&&')
}
}
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('build', ['jshint','concat', 'uglify','sass', 'autoprefixer','shell:build']);
};
[咕嚕可能重複 - 命令行參數,不工作](http://stackoverflow.com/questions/17012102/grunt-command-line-arguments-not-working) – Ian
更多信息:htt p://gruntjs.com/api/grunt.option – Ian