Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1const path = require('path');
2const fs = require('fs');
3
4try {
5 const hookSource = path.resolve(
6 __dirname,
7 '../../node_modules/husky-v4/sh/husky.sh'
8 );
9 const hook = path.resolve(__dirname, '../../.git/hooks/husky.sh');
10 const localHook = path.resolve(__dirname, '../../.git/hooks/husky.local.sh');
11 const gitConfig = path.resolve(__dirname, '../../.git/config');
12
13 let script = fs.readFileSync(hookSource, { encoding: 'utf-8' });
14 script = script.replace(`$(basename "$0")`, `$(basename "$0" .sh)`);
15
16 let config = fs.readFileSync(gitConfig, { encoding: 'utf-8' });
17 config = config.replace(/\s*hooksPath\s*=\s*\.husky\n?/g, '\n');
18
19 fs.writeFileSync(hook, script);
20 fs.writeFileSync(gitConfig, config);
21
22 fs.writeFileSync(localHook, 'packageManager=yarn\n' + 'cd "."\n');
23} catch {
24 // Ignore errors in ci etc
25}