diff --git a/src/installer/__tests__/index.ts b/src/installer/__tests__/index.ts index a4246349f..106307909 100644 --- a/src/installer/__tests__/index.ts +++ b/src/installer/__tests__/index.ts @@ -303,6 +303,15 @@ describe('install', (): void => { expect(hook).toMatch(huskyIdentifier) }) + it('should not install hooks if HUSKY_SKIP_INSTALL=1', (): void => { + mkdir(defaultGitDir, defaultHuskyDir) + writeFile('package.json', pkg) + + process.env.HUSKY_SKIP_INSTALL = '1' + install() + expect(exists(defaultHookFilename)).toBeFalsy() + }) + it('should not install hooks if HUSKY_SKIP_INSTALL=true', (): void => { mkdir(defaultGitDir, defaultHuskyDir) writeFile('package.json', pkg) diff --git a/src/installer/index.ts b/src/installer/index.ts index b8df12053..19a4174d5 100644 --- a/src/installer/index.ts +++ b/src/installer/index.ts @@ -137,7 +137,7 @@ export function install( const conf = getConf(userPkgDir) // Checks - if (process.env.HUSKY_SKIP_INSTALL === 'true') { + if (['1', 'true'].includes(process.env.HUSKY_SKIP_INSTALL || '')) { console.log( "HUSKY_SKIP_INSTALL environment variable is set to 'true',", 'skipping Git hooks installation.'