Skip to content

Commit 6d95675

Browse files
committed
Fix for ci
1 parent 653cf99 commit 6d95675

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

scripts/prepare/postinstall.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
const path = require('path');
22
const fs = require('fs');
33

4-
const hookSource = path.resolve(
5-
__dirname,
6-
'../../node_modules/husky-v4/sh/husky.sh'
7-
);
8-
const hook = path.resolve(__dirname, '../../.git/hooks/husky.sh');
9-
const localHook = path.resolve(__dirname, '../../.git/hooks/husky.local.sh');
10-
const gitConfig = path.resolve(__dirname, '../../.git/config');
4+
try {
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');
1112

12-
let script = fs.readFileSync(hookSource, { encoding: 'utf-8' });
13-
script = script.replace(`$(basename "$0")`, `$(basename "$0" .sh)`);
13+
let script = fs.readFileSync(hookSource, { encoding: 'utf-8' });
14+
script = script.replace(`$(basename "$0")`, `$(basename "$0" .sh)`);
1415

15-
let config = fs.readFileSync(gitConfig, { encoding: 'utf-8' });
16-
config = config.replace(/\s*hooksPath\s*=\s*\.husky\n?/g, '\n');
16+
let config = fs.readFileSync(gitConfig, { encoding: 'utf-8' });
17+
config = config.replace(/\s*hooksPath\s*=\s*\.husky\n?/g, '\n');
1718

18-
fs.writeFileSync(hook, script);
19-
fs.writeFileSync(gitConfig, config);
19+
fs.writeFileSync(hook, script);
20+
fs.writeFileSync(gitConfig, config);
2021

21-
fs.writeFileSync(localHook, 'packageManager=yarn\n' + 'cd "."\n');
22+
fs.writeFileSync(localHook, 'packageManager=yarn\n' + 'cd "."\n');
23+
} catch {
24+
// Ignore errors in ci etc
25+
}

0 commit comments

Comments
 (0)