File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 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'
44
55import { l } from '../log'
66
7+ const customDirHelp = 'https://typicode.github.io/husky/#/?id=custom-directory'
8+
79export function install ( dir = '.husky' ) : void {
810 // Ensure that we're inside a git repository
911 if ( cp . spawnSync ( 'git' , [ 'rev-parse' ] ) . status !== 0 ) {
10- // Do not fail to let projects downloaded as zip files have their dependencies installed
1112 l ( 'not a Git repository, skipping hooks installation' )
1213 return
1314 }
1415
15- // Ensure that we're not trying to install outside cwd
16+ // Ensure that we're not trying to install outside of cwd
1617 const absoluteHooksDir = path . resolve ( process . cwd ( ) , dir )
1718 if ( ! absoluteHooksDir . startsWith ( process . cwd ( ) ) ) {
18- throw new Error ( ' .. not allowed' )
19+ throw new Error ( ` .. not allowed (see ${ customDirHelp } )` )
1920 }
2021
2122 // Ensure that cwd is git top level
2223 if ( ! fs . existsSync ( '.git' ) ) {
23- throw new Error ( " .git can't be found" )
24+ throw new Error ( ` .git can't be found (see ${ customDirHelp } )` )
2425 }
2526
2627 try {
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ function format(file: string): string {
1919export function set ( file : string , cmd : string ) : void {
2020 const dir = path . dirname ( file )
2121 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+ )
2325 }
2426
2527 fs . writeFileSync ( file , data ( cmd ) , { mode : 0o0755 } )
You can’t perform that action at this time.
0 commit comments