Spawning vim from a node git hook
- by Lawrence Jones
I've got a project purely in coffeescript, with git hooks for deployment also written in cs. I don't really want to break away from the language just to use bash for a quick commit message formatter, but I've got a problem spawning vim from the commit-msg hook.
I've seen here that when piping to vim, the stdio is not necessarily set correctly to the tty streams. I get how that could cause a problem, but I don't exactly know how to get vim to load correctly using nodes spawn command. At the moment I have...
vim = (require 'child_process').spawn('vim', [file], stdio: 'inherit')
vim.on 'exit', (err) ->
console.log "Exited! [#{err}]"
cb?()
...which works fine to spawn a vim process that can r/w from the parents stdio, but when I use this in the hook things go wrong. Vim states that the stdio is not from terminal, and then once opened typing causes escape characters to pop up all over the place. Backspace for example, will produce ^?.
Any help would be appreciated!