simple-git-hooks
Version:
A simple, zero dependency tool for setting up git hooks for small projects
25 lines (19 loc) • 733 B
JavaScript
const {checkSimpleGitHooksInDependencies, getProjectRootDirectoryFromNodeModules, setHooksFromConfig} = require("./simple-git-hooks");
async function postinstall() {
let projectDirectory;
const parsedProjectDirectory = getProjectRootDirectoryFromNodeModules(process.cwd())
if (parsedProjectDirectory !== undefined) {
projectDirectory = parsedProjectDirectory
} else {
projectDirectory = process.cwd()
}
if (checkSimpleGitHooksInDependencies(projectDirectory)) {
try {
await setHooksFromConfig(projectDirectory)
} catch (err) {
console.log('[ERROR] Was not able to set git hooks. Reason: ' + err)
}
}
}
postinstall()