1.0.1 • Published 7 years ago

hook-commit v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

hook-commit

修改git hook的pre-commit,可以执行提交脚本

安装 (Install)

npm install --save-dev hook-commit

使用 (Usage)

安装完后会自动在项目根目录生成hook-commit脚本文件,每次pre-commit的时候都会执行该脚本检查,不会shell可以在脚本中执行js程序。

After installation, it will automaticlly generate a hook-commit bash file in root file directory. Every time before commit it will run this file.

返回值 (Return)

使用unix信号,成功执行返回0,非0即失败,不会通过commit。

If hook-commit return a singial 0, it will pass pre-commit, otherwise it means failed.

举个栗子 (Example)

hook-commit

#!/bin/bash
#Write your own pre-commit hook here.
./pre-commit.js
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0

pre-commit.js

'use strict';
	
const SUCCESS = true,
		FAIL = false;

if (SUCCESS) {
	process.exit(0);
} else {
	process.exit(1);
}