Skip to content

Commit

Permalink
Subsequent Init runs would clear Husky pre-commit typicode#1520
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Grande committed Sep 16, 2024
1 parent a2d942a commit e17a787
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ if (a == 'init') {
n = 'package.json'
s = f.readFileSync(n)
o = JSON.parse(s)
;(o.scripts ||= {}).prepare = 'husky'
; (o.scripts ||= {}).prepare = 'husky'
w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n')
p.stdout.write(i())
try { f.mkdirSync('.husky') } catch {}
w('.husky/pre-commit', (p.env.npm_config_user_agent?.split('/')[0] ?? 'npm') + ' test\n')
try {
f.mkdirSync('.husky')
w('.husky/pre-commit', (p.env.npm_config_user_agent?.split('/')[0] ?? 'npm') + ' test\n', { flag: 'wx' })
} catch { }
p.exit()
}

Expand Down

0 comments on commit e17a787

Please sign in to comment.