Skip to content

Commit

Permalink
Do not attach husky hooks when installing a repository as a dependenc…
Browse files Browse the repository at this point in the history
…y (instead of cloning)
  • Loading branch information
martnpaneq committed Nov 29, 2022
1 parent c7a1cb5 commit 5929954
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/postinstall.js
Expand Up @@ -7,4 +7,12 @@

/* eslint-env node */

require( 'husky' ).install();
const path = require( 'path' );
const fs = require( 'fs' );
const ROOT_DIRECTORY = path.join( __dirname, '..' );

// When installing a repository as a dependency, the `.git` directory does not exist.
// In such a case, husky should not attach its hooks as npm treats it as a package, not a git repository.
if ( fs.existsSync( path.join( ROOT_DIRECTORY, '.git' ) ) ) {
require( 'husky' ).install();
}

0 comments on commit 5929954

Please sign in to comment.