Skip to content

Commit

Permalink
fix: don't fail with old scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Sep 28, 2023
1 parent 90700bf commit 4119212
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ export default function(dir = '.husky'): void {

// Create the different files in dir/_/
fs.writeFileSync('.gitignore', '*') // .gitignore
fs.copyFileSync(new URL('../husky.sh', import.meta.url), 'husky.sh') // husky.sh
h.forEach(f => fs.writeFileSync(f, `#!/usr/bin/env sh\n. "\${0%/*}/husky.sh"`, { mode: 0o755 })) // hooks
fs.copyFileSync(new URL('../husky.sh', import.meta.url), 'h.sh')
h.forEach(f => fs.writeFileSync(f, `#!/usr/bin/env sh\n. "\${0%/*}/h.sh"`, { mode: 0o755 })) // hooks

// Create empty husky.sh to avoid making v5-8 hooks fail
// TODO: add deprecation notice later...
fs.writeFileSync('husky.sh', '')

// Configure Git
const { error: e } = git(['config', 'core.hooksPath', d])
Expand Down

0 comments on commit 4119212

Please sign in to comment.