编辑.git/hook/pre-commit 文件
?
#!/usr/bin/env node var spawn = require('child_process').spawn; var grunt = spawn('grunt',['-gruntfile', '/opt/ninja-server/grunt/Gruntfile.js']); grunt.stderr.on('data',function(data){ console.log(data.toString()); }); grunt.stdout.on('data',function(data){ data = data.toString(); console.log(data); if(data.indexOf('without error') > -1){ console.log('无语法错误,提交成功'); process.exit(0); }else if(data.indexOf('Aborted due to warnings') > -1){ console.log('存在语法错误,请先修改语法错误'); process.exit(1); } });
?