Git pre-commit hook没有运行

时间:2017-11-04 00:42:36

标签: node.js git bash pre-commit-hook

这是我的预提交钩子:

#!/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%)

我在这里做错了什么?

0 个答案:

没有答案