From 742781a264420dcc56a74b8f7c0bc659d23f0054 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 26 Mar 2021 16:52:31 +0800 Subject: [PATCH] Rewrite git hook --- .githooks/install.js | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .githooks/install.js diff --git a/.githooks/install.js b/.githooks/install.js new file mode 100644 index 0000000..5774839 --- /dev/null +++ b/.githooks/install.js @@ -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.'); +}); diff --git a/package.json b/package.json index d32fbac..a11b3b2 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "scripts": { "eslint": "eslint scripts/ source/js test/", - "prepare": "git config --local core.hooksPath .githooks/", + "prepare": "node .githooks/install.js", "stylint": "stylint source/css/", "test": "mocha test/index.js" },