-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
My env: MacOS 10.12.5, node 8.1.2, npm 5.0.3, grunt-githooks 0.6.0, zsh 5.2.
The same behavior on Windows 7, git version 2.9.0.windows.1.
My Grunt configs (example with pre-commit hook):
eslint...,
githooks: {
viaNode: {
'pre-commit': 'eslint'
},
viaShell: {
options: {
hashbang: '#!/bin/sh',
template: './node_modules/grunt-githooks/templates/shell.hb',
startMarker: '## LET THE FUN BEGIN',
endMarker: '## PARTY IS OVER'
},
'pre-commit': 'eslint'
}
}
Expected behavior
If I use grunt githooks --force then grunt-githooks module should drop existed file .git/hooks/pre-commit aka recreate it with new template.
Actual behavior
Message in CLI is shown, but file in fact is not changed.
Steps to reproduce
- run
grunt githooks:viaNodeit will create default templated pre-commit file. - open
.git/hooks/pre-commitfile, it's created using Node template. - run
grunt githooks:viaShellit will throw warning "A hook already exist for pre-commit but doesn't seem to be written in the same language as the binding script. Use --force to continue." - run
grunt githooks:viaShell --forceit will throw warning "A hook already exist for pre-commit but doesn't seem to be written in the same language as the binding script. Used --force, continuing." - open
.git/hooks/pre-commitfile, it's still the same (node-templated). - Delete file
.git/hooks/pre-commit - run again
grunt githooks:viaShell - and now file
.git/hooks/pre-commitcreated from dedicated Shell-like template.
My version of files:
- Node-Template-Based:
#!/usr/bin/env node
// GRUNT-GITHOOKS START
var exec = require('child_process').exec;
exec('grunt eslint', {
cwd: '/Users/alund/prj/builders'
}, function (err, stdout, stderr) {
var exitCode = 0;
if (err) {
console.log(stderr || err);
exitCode = -1;
}
process.exit(exitCode);
}).stdout.on('data', function (chunk){
process.stdout.write(chunk);
});
// GRUNT-GITHOOKS END
Shell-template-based + Gruntfile.config:
#!/bin/sh
## LET THE FUN BEGIN
(cd "/Users/alund/prj/builders" && grunt eslint)
## PARTY IS OVER
Changes to discuss
If such behavior is designed, then IMHO it's odd. What the exactly it continues?
So far, I delete file manually and re-run command. If --force really worked, I could avoid such monkey job :)
So what people think about it?
cc/ @rhumaric @franz-josef-kaiser
Reactions are currently unavailable