2

As part of my grunt:build command, I run a shell task that builds my jekyll site, commits the project, and pushes it to github. The only problem is the commit message. I'd love to be able to call grunt:build and also pass in a string which will become my commit message. But I'm not really sure how to make that work. Any thoughts?

Here are the relevant parts of my 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']);

};
Bryce Johnson
  • 6,689
  • 6
  • 40
  • 51
  • possible duplicate of [Grunt - Command Line Arguments, not working](http://stackoverflow.com/questions/17012102/grunt-command-line-arguments-not-working) – Ian Feb 15 '14 at 15:54
  • More info: http://gruntjs.com/api/grunt.option – Ian Feb 15 '14 at 15:56

1 Answers1

5

Try grunt.option() (http://gruntjs.com/api/grunt.option):

'git commit -am "' + grunt.option('commit-msg') + '"',

and running with: grunt build --commit-msg="test commit"

Kyle Robinson Young
  • 13,732
  • 1
  • 47
  • 38