bun-git-hooks 0.2.4 → 0.2.6
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 +12 -3
- package/dist/index.js +9 -1
- package/package.json +1 -1
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.
|
|
607
|
+
var version = "0.2.6";
|
|
608
608
|
|
|
609
609
|
// src/git-hooks.ts
|
|
610
610
|
import fs from "fs";
|
|
@@ -797,6 +797,7 @@ var config = await loadConfig({
|
|
|
797
797
|
cwd: resolve2(__dirname, ".."),
|
|
798
798
|
defaultConfig
|
|
799
799
|
});
|
|
800
|
+
console.log("cwd", resolve2(__dirname, ".."));
|
|
800
801
|
|
|
801
802
|
// src/git-hooks.ts
|
|
802
803
|
var VALID_GIT_HOOKS = [
|
|
@@ -875,19 +876,26 @@ function getGitProjectRoot(directory = process3.cwd()) {
|
|
|
875
876
|
function setHooksFromConfig(projectRootPath = process3.cwd(), options = {}) {
|
|
876
877
|
if (!config || Object.keys(config).length === 0)
|
|
877
878
|
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");
|
|
879
|
+
console.log("setHooksFromConfig config", config);
|
|
878
880
|
const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
|
|
881
|
+
console.log("hookKeys", hookKeys);
|
|
879
882
|
const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
|
|
883
|
+
console.log("isValidConfig", isValidConfig);
|
|
880
884
|
if (!isValidConfig)
|
|
881
885
|
throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
|
|
882
886
|
const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
|
|
883
887
|
for (const hook of VALID_GIT_HOOKS) {
|
|
888
|
+
console.log("hook", hook);
|
|
884
889
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
890
|
+
console.log("hook in config");
|
|
885
891
|
if (!config[hook])
|
|
886
892
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
887
893
|
console.log(`Hook ${hook}: `, config[hook]);
|
|
888
894
|
_setHook(hook, config[hook], projectRootPath);
|
|
889
|
-
} else if (!preserveUnused.includes(hook))
|
|
895
|
+
} else if (!preserveUnused.includes(hook)) {
|
|
896
|
+
console.log("Remove hook", hook);
|
|
890
897
|
_removeHook(hook, projectRootPath);
|
|
898
|
+
}
|
|
891
899
|
}
|
|
892
900
|
}
|
|
893
901
|
function _setHook(hook, command, projectRoot = process3.cwd()) {
|
|
@@ -933,7 +941,8 @@ cli.command("[configPath]", "Install git hooks, optionally from specified config
|
|
|
933
941
|
console.log("[DEBUG] Config path:", configPath || "using default");
|
|
934
942
|
console.log("[DEBUG] Working directory:", process4.cwd());
|
|
935
943
|
}
|
|
936
|
-
|
|
944
|
+
console.log("setHooksFromConfig", { configFile: configPath });
|
|
945
|
+
setHooksFromConfig(process4.cwd(), { configFile: configPath });
|
|
937
946
|
console.log("[INFO] Successfully set all git hooks");
|
|
938
947
|
} catch (err) {
|
|
939
948
|
console.error("[ERROR] Was not able to set git hooks. Error:", err);
|
package/dist/index.js
CHANGED
|
@@ -524,6 +524,7 @@ var config = await loadConfig({
|
|
|
524
524
|
cwd: B(__dirname, ".."),
|
|
525
525
|
defaultConfig
|
|
526
526
|
});
|
|
527
|
+
console.log("cwd", B(__dirname, ".."));
|
|
527
528
|
// src/git-hooks.ts
|
|
528
529
|
var { default: fs} = (() => ({}));
|
|
529
530
|
init_process();
|
|
@@ -646,19 +647,26 @@ function _getPackageJson(projectPath = j2.cwd()) {
|
|
|
646
647
|
function setHooksFromConfig(projectRootPath = j2.cwd(), options = {}) {
|
|
647
648
|
if (!config || Object.keys(config).length === 0)
|
|
648
649
|
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");
|
|
650
|
+
console.log("setHooksFromConfig config", config);
|
|
649
651
|
const hookKeys = Object.keys(config).filter((key) => key !== "preserveUnused" && key !== "verbose");
|
|
652
|
+
console.log("hookKeys", hookKeys);
|
|
650
653
|
const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
|
|
654
|
+
console.log("isValidConfig", isValidConfig);
|
|
651
655
|
if (!isValidConfig)
|
|
652
656
|
throw new Error("[ERROR] Config was not in correct format. Please check git hooks or options name");
|
|
653
657
|
const preserveUnused = Array.isArray(config.preserveUnused) ? config.preserveUnused : config.preserveUnused ? VALID_GIT_HOOKS : [];
|
|
654
658
|
for (const hook of VALID_GIT_HOOKS) {
|
|
659
|
+
console.log("hook", hook);
|
|
655
660
|
if (Object.prototype.hasOwnProperty.call(config, hook)) {
|
|
661
|
+
console.log("hook in config");
|
|
656
662
|
if (!config[hook])
|
|
657
663
|
throw new Error(`[ERROR] Command for ${hook} is not set`);
|
|
658
664
|
console.log(`Hook ${hook}: `, config[hook]);
|
|
659
665
|
_setHook(hook, config[hook], projectRootPath);
|
|
660
|
-
} else if (!preserveUnused.includes(hook))
|
|
666
|
+
} else if (!preserveUnused.includes(hook)) {
|
|
667
|
+
console.log("Remove hook", hook);
|
|
661
668
|
_removeHook(hook, projectRootPath);
|
|
669
|
+
}
|
|
662
670
|
}
|
|
663
671
|
}
|
|
664
672
|
function _setHook(hook, command, projectRoot = j2.cwd()) {
|
package/package.json
CHANGED