From 11beb8471882ec3ded864e1f3261e153068bbf35 Mon Sep 17 00:00:00 2001 From: Shalin Shah Date: Sun, 24 Mar 2024 16:09:18 +0530 Subject: [PATCH] Feature: Added check for existing commands inside the prepare script. --- bin.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin.mjs b/bin.mjs index d954ed9ac..3f6a4497b 100755 --- a/bin.mjs +++ b/bin.mjs @@ -11,7 +11,7 @@ if (a == 'init') { n = 'package.json' s = f.readFileSync(n) o = JSON.parse(s) - ;(o.scripts ||= {}).prepare = 'husky' + ;(o.scripts ||= {}).prepare = '' === (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 {} @@ -23,4 +23,4 @@ d = c => console.error(`${c} command is deprecated`) if (['add', 'set', 'uninstall'].includes(a)) { d(a); p.exit(1) } if (a == 'install') d(a) -p.stdout.write(i(a == 'install' ? undefined : a)) \ No newline at end of file +p.stdout.write(i(a == 'install' ? undefined : a))