I'm trying to enforce a git commit message policy to keep my repositories clean and tidy. I've seen the official docs about server-side and client-side hooks and then I bumped on husky.
So far I could work with the first but couldn't set up husky, I've still got plenty to learn. The main idea is to be able to work on a new workstation without having to manually set up any client-side hooks.
Could someone explain how I can set up husky to check my commit messages or even make an example?
This is my commit-msg hook in project-root/githooks folder:  
#!/usr/bin/env ruby
message_file = ARGV[0]
message = File.read(message_file)
$regex = /([resolved|fixed]) #([0-9])* ([A-Z])\w+/
if !$regex.match(message)  
  puts "[POLICY] Your message is not formatted correctly!"  
  puts "Message format must be like:"  
  puts "resolved #123 Case title (for features)"  
  puts "fixed #123 Case title    (for bugs)"  
  puts "First letter of 'Case title' must be capitalized!"  
  exit 1  
end  
I've tried to add the script to the package.json:
"scripts": {  
  ... : ...,  
  "commitmsg": "sh hooks/commit-msg",  
  ... : ...  
}  
The hook does not work. All messages pass. If put in .git/hooks it works normally.
Here's a screenshot of a test project with the package.json, the commit-msg hook and the error it gives out.
The same hook, put in .git/hooks folder, works just fine.

 
     
     
    
 
     
    