这是我的预提交钩子:
#!/bin/sh
exec node build.js
当我将pre-commit
更改为pre-commit.sh
并运行它时,该代码正常工作,当我在终端中运行exec node build.js
时,它也能正确执行。构建文件工作正常。
这是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)
我认为它可能在写入新文件之前过早地(可能是)结束,但在这种情况下终端仍应显示初始写入输出。
这是我在提交时的输出(事先已更改pdf以测试是否覆盖了新的更改):
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%)
我在这里做错了什么?