/
scripts.ts.snap
121 lines (99 loc) 路 3.24 KB
/
scripts.ts.snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`hookScript should match snapshot 1`] = `
"#!/bin/sh
# husky
# Created by Husky v4.3.3 (https://github.com/typicode/husky#readme)
# At: <locale date string>
# From: /home/typicode/projects/foo-package (https://github.com/foo/foo-package)
. \\"$(dirname \\"$0\\")/husky.sh\\"
"
`;
exports[`localScript should match snapshot 1`] = `
"# Created by Husky v4.3.3 (https://github.com/typicode/husky#readme)
# At: <locale date string>
# From: /home/typicode/projects/foo-package (https://github.com/foo/foo-package)
packageManager=npm
cd \\".\\"
"
`;
exports[`mainScript should match snapshot 1`] = `
"# Created by Husky v4.3.3 (https://github.com/typicode/husky#readme)
# At: <locale date string>
# From: /home/typicode/projects/foo-package (https://github.com/foo/foo-package)
debug () {
if [ \\"$HUSKY_DEBUG\\" = \\"true\\" ] || [ \\"$HUSKY_DEBUG\\" = \\"1\\" ]; then
echo \\"husky:debug $1\\"
fi
}
command_exists () {
command -v \\"$1\\" >/dev/null 2>&1
}
run_command () {
if command_exists \\"$1\\"; then
\\"$@\\" husky-run $hookName \\"$gitParams\\"
exitCode=\\"$?\\"
debug \\"$* husky-run exited with $exitCode exit code\\"
if [ $exitCode -eq 127 ]; then
echo \\"Can't find Husky, skipping $hookName hook\\"
echo \\"You can reinstall it using 'npm install husky --save-dev' or delete this hook\\"
else
exit $exitCode
fi
else
echo \\"Can't find $1 in PATH: $PATH\\"
echo \\"Skipping $hookName hook\\"
exit 0
fi
}
hookIsDefined () {
grep -qs $hookName \\\\
package.json \\\\
.huskyrc \\\\
.huskyrc.json \\\\
.huskyrc.yaml \\\\
.huskyrc.yml
}
huskyVersion=\\"4.3.3\\"
gitParams=\\"$*\\"
hookName=\\"$(basename \\"$0\\")\\"
debug \\"husky v$huskyVersion - $hookName\\"
# Skip if HUSKY_SKIP_HOOKS is set
if [ \\"$HUSKY_SKIP_HOOKS\\" = \\"true\\" ] || [ \\"$HUSKY_SKIP_HOOKS\\" = \\"1\\" ]; then
debug \\"HUSKY_SKIP_HOOKS is set to $HUSKY_SKIP_HOOKS, skipping hook\\"
exit 0
fi
# Source user var and change directory
. \\"$(dirname \\"$0\\")/husky.local.sh\\"
debug \\"Current working directory is $(pwd)\\"
# Skip fast if hookName is not defined
# Don't skip if .huskyrc.js or .huskyrc.config.js are used as the heuristic could
# fail due to the dynamic aspect of JS. For example:
# \`\\"pre-\\" + \\"commit\\"\` or \`require('./config/hooks')\`)
if [ ! -f .huskyrc.js ] && [ ! -f huskyrc.cjs ] && [ ! -f husky.config.js ] && [ ! -f husky.config.cjs ] && ! hookIsDefined; then
debug \\"$hookName config not found, skipping hook\\"
exit 0
fi
# Source user ~/.huskyrc
if [ -f ~/.huskyrc ]; then
debug \\"source ~/.huskyrc\\"
. ~/.huskyrc
fi
# Set HUSKY_GIT_STDIN from stdin
case $hookName in
\\"pre-push\\"|\\"post-rewrite\\")
export HUSKY_GIT_STDIN=\\"$(cat)\\";;
esac
# Windows 10, Git Bash and Yarn 1 installer
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
# Run husky-run with the package manager used to install Husky
case $packageManager in
\\"npm\\") run_command npx --no-install;;
\\"npminstall\\") run_command npx --no-install;;
\\"pnpm\\") run_command pnpx --no-install;;
\\"yarn\\") run_command yarn run --silent;;
*) echo \\"Unknown package manager: $packageManager\\"; exit 0;;
esac
"
`;