Skip to content

Commit

Permalink
Merge pull request #150 from cksource/i/2253-2
Browse files Browse the repository at this point in the history
Internal: Do not attach husky hooks when installing a repository as a dependency (instead of cloning).
  • Loading branch information
pomek authored Nov 29, 2022
2 parents 01c7fc0 + 203e8f8 commit 4a6f90a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/postinstall.js
Original file line number Diff line number Diff line change
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 4a6f90a

Please sign in to comment.