From e17a78700a06db75c1c915e53d966b11639612b5 Mon Sep 17 00:00:00 2001 From: Fabio Grande Date: Mon, 16 Sep 2024 21:43:11 +0200 Subject: [PATCH] Subsequent Init runs would clear Husky pre-commit #1520 --- bin.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin.js b/bin.js index 73ee3eda..6a100f34 100755 --- a/bin.js +++ b/bin.js @@ -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() }