Costa Costa - 18 days ago 7
Javascript Question

Writing a git post-commit file in node.js

I'm trying to write a git post-commit file in node.js and I'm having trouble.

The file seems to have to be named

post-commit
in the
.git/hooks
directory. Since that file can't have an extension, my vim editor won't persistently give it javascript syntax highlighting, and thus none of my snippets work, and a variety of other challenges present themselves.

What can I do? Tell git to run post-commit.js or tell vim to consider this file javascript, but that doesn't persist.

Thoughts?

Answer

You can have the post-commit file run a separate JavaScript file.

post-commit:

#!/bin/bash/
node yourJavascriptFile.js