1212 * - SKIP_COMMITMSG=1: Skip the entire commit-msg hook
1313 * - GIT_HOOKS_VERBOSE=1: Enable verbose output for debugging
1414 */
15- import { fs } from 'zx'
15+ import { fs , path } from 'zx'
16+ import { fileURLToPath } from 'url'
1617import validateBranchNameConfig from '../validate-branch-name.config.cjs'
1718import { getCurrentBranch , GitHook , log , runHook , runTool , runWithRunner } from './shared/index.ts'
1819
@@ -117,11 +118,7 @@ function extractTicketId(branchName: string, config: BranchConfig): string | nul
117118 * Validate branch name using validate-branch-name tool
118119 */
119120async function validateBranchName ( branchName : string ) : Promise < boolean > {
120- const binPath = './node_modules/.bin/validate-branch-name'
121- if ( ! ( await fs . pathExists ( binPath ) ) ) {
122- log . error ( 'validate-branch-name not found in node_modules/.bin/' )
123- return false
124- }
121+ const binPath = 'validate-branch-name'
125122
126123 return await runTool ( 'Branch Name' , 'Validating branch name...' , async ( ) => {
127124 try {
@@ -147,14 +144,14 @@ async function validateBranchName(branchName: string): Promise<boolean> {
147144 * Lint commit message using commitlint
148145 */
149146async function lintCommitMessage ( commitFile : string ) : Promise < boolean > {
150- const binPath = './node_modules/.bin/ commitlint'
151- if ( ! ( await fs . pathExists ( binPath ) ) ) {
152- log . error ( 'commitlint not found in node_modules/.bin/' )
153- return false
154- }
147+ const binPath = 'commitlint'
148+
149+ const __filename = fileURLToPath ( import . meta . url )
150+ const scriptDir = path . dirname ( __filename )
151+ const configPath = path . resolve ( scriptDir , '../commitlint.config.ts' )
155152
156153 return await runTool ( 'Commitlint' , 'Validating commit message format...' , async ( ) => {
157- await runWithRunner ( [ binPath , '--edit' , commitFile ] )
154+ await runWithRunner ( [ binPath , '--config' , configPath , '-- edit', commitFile ] )
158155 } )
159156}
160157
@@ -214,7 +211,6 @@ async function appendTicketFooter(commitFile: string): Promise<boolean> {
214211 return false
215212 }
216213}
217-
218214await runHook ( GitHook . CommitMsg , async ( ) => {
219215 const [ commitFile ] = process . argv . slice ( 3 ) // Skip node, script, and hook args
220216
0 commit comments