Skip to content

Commit

Permalink
Fix HUSKY_SKIP_INSTALL=1 not skipping install (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicdoe authored and typicode committed Jun 27, 2019
1 parent ca57293 commit 479e08a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/installer/__tests__/index.ts
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/installer/index.ts
Expand Up @@ -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.'
Expand Down

0 comments on commit 479e08a

Please sign in to comment.