From 4ad2d0fede9d43e975ead20a35c46f8f81f53975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B5=D1=87=D0=BA=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86?= Date: Fri, 9 Aug 2024 10:42:45 +0300 Subject: [PATCH 1/2] Added package.json formatting check Previously, the package file.json was formatted with only two spaces or tabs. Added a search for the original formatting. --- .gitignore | 3 ++- .husky/pre-commit | 2 +- bin.js | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2f15a6822..4a24158e5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ docs/.vitepress/dist docs/.env docs/sponsorkit/.cache.json docs/sponsorkit/sponsors.json -docs/sponsorkit/sponsors.png \ No newline at end of file +docs/sponsorkit/sponsors.png +.vscode/ diff --git a/.husky/pre-commit b/.husky/pre-commit index 778fb0b71..72c4429bc 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -./test.sh \ No newline at end of file +npm test diff --git a/bin.js b/bin.js index 40d28590c..a584ba11a 100755 --- a/bin.js +++ b/bin.js @@ -9,10 +9,15 @@ a = p.argv[2] if (a == 'init') { n = 'package.json' - s = f.readFileSync(n) + s = f.readFileSync(n, 'utf8') o = JSON.parse(s) + + const indentMatch = s.match(/^[\t ]+/m) + const indent = indentMatch ? indentMatch[0].length : 2 + ;(o.scripts ||= {}).prepare = 'husky' - w(n, JSON.stringify(o, 0, /\t/.test(s) ? '\t' : 2) + '\n') + w(n, JSON.stringify(o, null, indent) + '\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') @@ -23,4 +28,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)) From 5830d6f299dbffe1e1e2c58ee999c28020228931 Mon Sep 17 00:00:00 2001 From: Vse7en Date: Sun, 8 Sep 2024 23:15:53 +0300 Subject: [PATCH 2/2] Create V7 --- .husky/V7 | 1 + 1 file changed, 1 insertion(+) create mode 100644 .husky/V7 diff --git a/.husky/V7 b/.husky/V7 new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.husky/V7 @@ -0,0 +1 @@ +