forked from finos/git-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request finos#196 from vaibssingh/fix/188-add-prepare-hook
fix: add prepare hook for husky install
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ======= | ||
// Import. | ||
// ======= | ||
|
||
const { execSync } = require('child_process'); | ||
const { existsSync } = require('fs'); | ||
|
||
// =========== | ||
// File paths. | ||
// =========== | ||
|
||
const FILE_COMMIT = './.husky/commit-msg'; | ||
const FILE_HUSKY = './.husky/_/husky.sh'; | ||
|
||
// ========= | ||
// Commands. | ||
// ========= | ||
|
||
const COMMIT_MSG_STRING = `'npx --no -- commitlint --edit $'{1}''` | ||
const CLI_COMMIT = `npx husky add .husky/commit-msg ${COMMIT_MSG_STRING}`; | ||
const CLI_HUSKY = 'npx husky install'; | ||
|
||
// ============== | ||
// Husky install. | ||
// ============== | ||
|
||
// this will create .husky/_/husky.sh if it does not yet exist. | ||
if (!existsSync(FILE_HUSKY)) { | ||
global.console.log(CLI_HUSKY); | ||
execSync(CLI_HUSKY); | ||
} | ||
|
||
// ==================== | ||
// Add pre-commit hook. | ||
// ==================== | ||
|
||
// this will create .husky/commit-msg if it does not yet exist. | ||
if (!existsSync(FILE_COMMIT)) { | ||
global.console.log(CLI_COMMIT); | ||
execSync(CLI_COMMIT); | ||
} |