diff --git a/bin.js b/bin.js index 9d98ccf50..275f026f2 100755 --- a/bin.js +++ b/bin.js @@ -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') @@ -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)) \ No newline at end of file +process.stdout.write(i(a == 'install' ? undefined : a))