bun-git-hooks 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -604,7 +604,7 @@ class CAC extends EventEmitter {
604
604
  }
605
605
  }
606
606
  // package.json
607
- var version = "0.2.4";
607
+ var version = "0.2.5";
608
608
 
609
609
  // src/git-hooks.ts
610
610
  import fs from "fs";
@@ -875,19 +875,26 @@ function getGitProjectRoot(directory = process3.cwd()) {
875
875
  function setHooksFromConfig(projectRootPath = process3.cwd(), options = {}) {
876
876
  if (!config || Object.keys(config).length === 0)
877
877
  throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or `git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
878
+ console.log("setHooksFromConfig config", config);
878
879
  const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
880
+ console.log("hookKeys", hookKeys);
879
881
  const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
882
+ console.log("isValidConfig", isValidConfig);
880
883
  if (!isValidConfig)
881
884
  throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
882
885
  const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
883
886
  for (const hook of VALID_GIT_HOOKS) {
887
+ console.log("hook", hook);
884
888
  if (Object.prototype.hasOwnProperty.call(config, hook)) {
889
+ console.log("hook in config");
885
890
  if (!config[hook])
886
891
  throw new Error(`[ERROR] Command for ${hook} is not set`);
887
892
  console.log(`Hook ${hook}: `, config[hook]);
888
893
  _setHook(hook, config[hook], projectRootPath);
889
- } else if (!preserveUnused.includes(hook))
894
+ } else if (!preserveUnused.includes(hook)) {
895
+ console.log("Remove hook", hook);
890
896
  _removeHook(hook, projectRootPath);
897
+ }
891
898
  }
892
899
  }
893
900
  function _setHook(hook, command, projectRoot = process3.cwd()) {
@@ -933,7 +940,8 @@ cli.command("[configPath]", "Install git hooks, optionally from specified config
933
940
  console.log("[DEBUG] Config path:", configPath || "using default");
934
941
  console.log("[DEBUG] Working directory:", process4.cwd());
935
942
  }
936
- setHooksFromConfig(process4.cwd());
943
+ console.log("setHooksFromConfig", { configFile: configPath });
944
+ setHooksFromConfig(process4.cwd(), { configFile: configPath });
937
945
  console.log("[INFO] Successfully set all git hooks");
938
946
  } catch (err) {
939
947
  console.error("[ERROR] Was not able to set git hooks. Error:", err);
package/dist/index.js CHANGED
@@ -646,19 +646,26 @@ function _getPackageJson(projectPath = j2.cwd()) {
646
646
  function setHooksFromConfig(projectRootPath = j2.cwd(), options = {}) {
647
647
  if (!config || Object.keys(config).length === 0)
648
648
  throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or `git-hooks.config.{ts,js,mjs,cjs,mts,cts,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
649
+ console.log("setHooksFromConfig config", config);
649
650
  const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
651
+ console.log("hookKeys", hookKeys);
650
652
  const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
653
+ console.log("isValidConfig", isValidConfig);
651
654
  if (!isValidConfig)
652
655
  throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
653
656
  const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
654
657
  for (const hook of VALID_GIT_HOOKS) {
658
+ console.log("hook", hook);
655
659
  if (Object.prototype.hasOwnProperty.call(config, hook)) {
660
+ console.log("hook in config");
656
661
  if (!config[hook])
657
662
  throw new Error(`[ERROR] Command for ${hook} is not set`);
658
663
  console.log(`Hook ${hook}: `, config[hook]);
659
664
  _setHook(hook, config[hook], projectRootPath);
660
- } else if (!preserveUnused.includes(hook))
665
+ } else if (!preserveUnused.includes(hook)) {
666
+ console.log("Remove hook", hook);
661
667
  _removeHook(hook, projectRootPath);
668
+ }
662
669
  }
663
670
  }
664
671
  function _setHook(hook, command, projectRoot = j2.cwd()) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-git-hooks",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "description": "A modern, zero dependency tool for managing git hooks in Bun projects.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",