File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -4,23 +4,24 @@ import path from 'path'
4
4
5
5
import { l } from '../log'
6
6
7
+ const customDirHelp = 'https://typicode.github.io/husky/#/?id=custom-directory'
8
+
7
9
export function install ( dir = '.husky' ) : void {
8
10
// Ensure that we're inside a git repository
9
11
if ( cp . spawnSync ( 'git' , [ 'rev-parse' ] ) . status !== 0 ) {
10
- // Do not fail to let projects downloaded as zip files have their dependencies installed
11
12
l ( 'not a Git repository, skipping hooks installation' )
12
13
return
13
14
}
14
15
15
- // Ensure that we're not trying to install outside cwd
16
+ // Ensure that we're not trying to install outside of cwd
16
17
const absoluteHooksDir = path . resolve ( process . cwd ( ) , dir )
17
18
if ( ! absoluteHooksDir . startsWith ( process . cwd ( ) ) ) {
18
- throw new Error ( ' .. not allowed' )
19
+ throw new Error ( ` .. not allowed (see ${ customDirHelp } )` )
19
20
}
20
21
21
22
// Ensure that cwd is git top level
22
23
if ( ! fs . existsSync ( '.git' ) ) {
23
- throw new Error ( " .git can't be found" )
24
+ throw new Error ( ` .git can't be found (see ${ customDirHelp } )` )
24
25
}
25
26
26
27
try {
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ function format(file: string): string {
19
19
export function set ( file : string , cmd : string ) : void {
20
20
const dir = path . dirname ( file )
21
21
if ( ! fs . existsSync ( dir ) ) {
22
- throw new Error ( `can't create hook, ${ dir } directory doesn't exist` )
22
+ throw new Error (
23
+ `can't create hook, ${ dir } directory doesn't exist (try running husky install)` ,
24
+ )
23
25
}
24
26
25
27
fs . writeFileSync ( file , data ( cmd ) , { mode : 0o0755 } )
You can’t perform that action at this time.
0 commit comments