From d09132834bcd1b482a729a4cb3b9ccca54ee9a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 1 Feb 2024 11:29:25 +0200 Subject: [PATCH] fix: tab detection on install command (#1376) --- bin.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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))