Skip to content

Commit

Permalink
chore: refactor Git commands
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Nov 8, 2024
1 parent a25dbf8 commit 34bba7b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/commands/git/remove-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class extends Command {
res = await this.#getHooksPath( process.cli.options.global );
if ( !res.ok ) return res;

const hooksPath = res.data;
const { git, hooksPath } = res.data;

// remove "pre-commit" hook
if ( fs.existsSync( path.join( hooksPath, "pre-commit" ) ) ) {
Expand All @@ -46,6 +46,14 @@ export default class extends Command {
console.log( `Git "commit-msg" hook not installed` );
}

if ( !process.cli.options.global ) {
res = await git.run( "config", "unset", "core.hookspath" );

if ( !res.ok ) return res;

console.log( `Git config updated` );
}

return result( 200 );
}

Expand All @@ -70,7 +78,7 @@ export default class extends Command {
git = pkg.git;
}

res = await git.run( "config", ...args, "--get", "core.hookspath" );
res = await git.run( "config", "get", ...args, "core.hookspath" );

if ( !res.ok ) return res;

Expand All @@ -92,6 +100,9 @@ export default class extends Command {
}
}

return result( 200, hooksPath );
return result( 200, {
git,
hooksPath,
} );
}
}

0 comments on commit 34bba7b

Please sign in to comment.