Skip to content

Commit

Permalink
extract getGitHooks function in installer/index.ts (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunnble authored and typicode committed Jul 25, 2019
1 parent b7c2705 commit f955c07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/installer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ function isInNodeModules(dir: string): boolean {
return (dir.match(/node_modules/g) || []).length > 1
}

function getGitHooksDir(gitDir: string): string {
return path.join(gitDir, 'hooks')
}

function getHooks(gitDir: string): string[] {
const gitHooksDir = path.join(gitDir, 'hooks')
const gitHooksDir = getGitHooksDir(gitDir)
return hookList.map((hookName: string): string =>
path.join(gitHooksDir, hookName)
)
Expand Down Expand Up @@ -158,7 +162,7 @@ export function install(
}

// Create hooks directory if it doesn't exist
const gitHooksDir = path.join(gitDir, 'hooks')
const gitHooksDir = getGitHooksDir(gitDir)
if (!fs.existsSync(gitHooksDir)) {
fs.mkdirSync(gitHooksDir)
}
Expand Down

0 comments on commit f955c07

Please sign in to comment.