Here's my pre-commit hook:
#!/bin/sh
exec node build.js
That code works fine when I change pre-commit to pre-commit.sh and run it, it also executes correctly when I just run exec node build.js in the terminal. The build file works fine.
Here's build.js:
var fs = require("fs")
var through2 = require('through2');
var markdownPdf = require("markdown-pdf")
var removeMarkdown = require("remove-markdown")
var resume = fs.createReadStream("README.md")
var pdf = fs.createWriteStream("Resume - Desmond Weindorf.pdf")
var txt = fs.createWriteStream("Resume - Desmond Weindorf.txt")
var md = fs.createWriteStream("Resume - Desmond Weindorf.md")
process.stdout.write('Building other file types...\n')
// pdf
resume.pipe(markdownPdf({ paperBorder: "1.4cm" })).pipe(pdf)
// txt
resume.pipe(through2(function(line, _, next) {
this.push(removeMarkdown(line.toString()) + '\n');
next()
})).pipe(txt)
// md
resume.pipe(md)
I thought it might be ending prematurely (and probably is) before the new files are written to, but the terminal should still display the initial write output in that case.
This was my output on a commit (the pdf was changed beforehand to test if it was overwriting with new changes):
Desmonds-MacBook-Pro:resume desmond$ git commit -am "updated resume"
[master 7faab35] updated resume
4 files changed, 36 insertions(+), 34 deletions(-)
rewrite Resume - Desmond Weindorf.pdf (81%)
What am I doing wrong here?