gruntjs - Launch grunt task passing params on git commit -
i starting grunt, have defined task , work charm:
module.exports = function(grunt) { grunt.initconfig({ jshint: { force: false, options: { evil: true, regexdash: true, browser: true, wsh: true, trailing: true, multistr: true, sub: true, loopfunc: true, expr: true, jquery: true, newcap: true, plusplus: false, curly: true, eqeqeq: true, globals: { jquery: true } }, src: ['workspace/**/*.js'] } }); grunt.loadnpmtasks('grunt-contrib-jshint'); grunt.registertask('default', ['jshint:src']); };
now, launch task passing src param (with git commited files).
i have tried pre-commit script in .git folder, does´t work:
var exec = require('child_process').exec; exec('grunt jshint', { cwd: 'c:\\workspace', src: 'subfolder\\**\\*.js' }, function (err, stdout, stderr) { console.log(stdout); var exitcode = 0; if (err) { console.log(stderr); exitcode = -1; } process.exit(exitcode); });
how can pass params in execution time grunt task?
thanks lot, best regards.
if want pass command line parameters grunt, have to:
- on command line, use syntax
--paramname=value
- in gruntfile, use
grunt.option('paramname')
so in case call
exec('grunt jshint --src=subfolder\\**\\*.js', {cwd: 'c:\\workspace'}, function (err, stdout, stderr) {...});
and gruntfile be:
jshint: { (...) src: [grunt.option('src')] }
Comments
Post a Comment