Rewrite git hook

This commit is contained in:
Mimi 2021-03-26 16:52:31 +08:00
parent be4d3bb6d9
commit 742781a264
2 changed files with 8 additions and 1 deletions

7
.githooks/install.js Normal file
View File

@ -0,0 +1,7 @@
const { spawn } = require('child_process');
const subprocess = spawn('git', ['config', '--local', 'core.hooksPath', '.githooks/']);
subprocess.on('error', () => {
console.error('Failed to install git hook.');
});

View File

@ -14,7 +14,7 @@
], ],
"scripts": { "scripts": {
"eslint": "eslint scripts/ source/js test/", "eslint": "eslint scripts/ source/js test/",
"prepare": "git config --local core.hooksPath .githooks/", "prepare": "node .githooks/install.js",
"stylint": "stylint source/css/", "stylint": "stylint source/css/",
"test": "mocha test/index.js" "test": "mocha test/index.js"
}, },