Skip to content

Commit

Permalink
fix: tab detection on install command (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Feb 1, 2024
1 parent 798f1ad commit d091328
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bin.js
Expand Up @@ -6,9 +6,10 @@ let a = process.argv[2]

if (a == 'init') {
let p = 'package.json'
let d = JSON.parse(f.readFileSync(p))
let s = f.readFileSync(p);
let d = JSON.parse(s)
; (d.scripts ||= {}).prepare = 'husky'
w('package.json', JSON.stringify(d, null, /\t/.test() ? '\t' : 2) + '\n')
w('package.json', JSON.stringify(d, null, /\t/.test(s) ? '\t' : 2) + '\n')
process.stdout.write(i())
try { f.mkdirSync('.husky') } catch { }
w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test\n')
Expand All @@ -19,4 +20,4 @@ let d = c => console.error(`${c} command is deprecated`)
if (['add', 'set', 'uninstall'].includes(a)) { d(a); process.exit(1) }
if (a == 'install') d(a)

process.stdout.write(i(a == 'install' ? undefined : a))
process.stdout.write(i(a == 'install' ? undefined : a))

0 comments on commit d091328

Please sign in to comment.