我目前正在使用grunt git hooks实现预提交钩子。我是使用这个插件的新手,我还不清楚我是否可以使用这个插件来做我最初打算做的事情。
目前,我为每个 git 提交触发了两个 grunt 任务,如下所示。
githooks: {
all: {
'pre-commit' : 'compass requirejs'
}
}
上面生成 git pre-commit 钩子,如下所示。
#!/usr/bin/env node
// GRUNT-GITHOOKS START
var exec = require('child_process').exec;
exec('grunt compass requirejs', {
cwd: 'C:\\development\\Sourcecode\\qnb-home'
}, function (err, stdout, stderr) {
console.log(stdout);
var exitCode = 0;
if (err) {
console.log(stderr);
exitCode = -1;
}
process.exit(exitCode);
});
// GRUNT-GITHOOKS END
虽然上述确保任务在 git 提交之前运行,但它不会将新创建的缩小文件(已编译的 SASS 和 r.js 文件)添加到现有提交中。
所以,我想git add --all
使用 grunt githooks 在预提交钩子中添加一个。这有可能吗?任何评论/答案将不胜感激。