bun-git-hooks 0.2.18 → 0.2.19

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
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  var __require = import.meta.require;
20
20
 
21
21
  // bin/cli.ts
22
- import process12 from "process";
22
+ import process11 from "process";
23
23
 
24
24
  // node_modules/@stacksjs/clarity/dist/index.js
25
25
  import { join, relative, resolve as resolve2 } from "path";
@@ -2085,25 +2085,26 @@ class CAC extends EventEmitter {
2085
2085
  }
2086
2086
  }
2087
2087
  // package.json
2088
- var version = "0.2.18";
2088
+ var version = "0.2.19";
2089
2089
 
2090
2090
  // src/git-hooks.ts
2091
2091
  import fs from "fs";
2092
2092
  import path from "path";
2093
- import process11 from "process";
2093
+ import process10 from "process";
2094
2094
 
2095
2095
  // src/config.ts
2096
2096
  import process9 from "process";
2097
2097
 
2098
2098
  // node_modules/bunfig/dist/index.js
2099
2099
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
2100
+ import { homedir } from "os";
2100
2101
  import { dirname as dirname2, resolve as resolve3 } from "path";
2101
- import process8 from "process";
2102
+ import process6 from "process";
2102
2103
  import { join as join3, relative as relative2, resolve as resolve22 } from "path";
2103
2104
  import process22 from "process";
2104
2105
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as readdirSync3, writeFileSync as writeFileSync4 } from "fs";
2105
2106
  import { dirname as dirname3, resolve as resolve4 } from "path";
2106
- import process6 from "process";
2107
+ import process7 from "process";
2107
2108
  import { Buffer as Buffer2 } from "buffer";
2108
2109
  import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, randomBytes as randomBytes2 } from "crypto";
2109
2110
  import { closeSync as closeSync2, createReadStream as createReadStream2, createWriteStream as createWriteStream2, existsSync as existsSync22, fsyncSync as fsyncSync2, openSync as openSync2, writeFileSync as writeFileSync22 } from "fs";
@@ -2261,7 +2262,7 @@ async function loadConfig3({
2261
2262
  cwd,
2262
2263
  defaultConfig: defaultConfig2
2263
2264
  }) {
2264
- const baseDir = cwd || process6.cwd();
2265
+ const baseDir = cwd || process7.cwd();
2265
2266
  const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
2266
2267
  const configPaths = [
2267
2268
  `${name}.config`,
@@ -2292,8 +2293,8 @@ async function loadConfig3({
2292
2293
  } catch {}
2293
2294
  return defaultConfig2;
2294
2295
  }
2295
- var defaultConfigDir2 = resolve4(process6.cwd(), "config");
2296
- var defaultGeneratedDir2 = resolve4(process6.cwd(), "src/generated");
2296
+ var defaultConfigDir2 = resolve4(process7.cwd(), "config");
2297
+ var defaultGeneratedDir2 = resolve4(process7.cwd(), "src/generated");
2297
2298
  function getProjectRoot2(filePath, options = {}) {
2298
2299
  let path = process22.cwd();
2299
2300
  while (path.includes("storage"))
@@ -3690,20 +3691,6 @@ function isObject22(item) {
3690
3691
  var log = new Logger2("bunfig", {
3691
3692
  showTags: true
3692
3693
  });
3693
- async function config22(nameOrOptions = { defaultConfig: {} }) {
3694
- if (typeof nameOrOptions === "string") {
3695
- const { cwd } = await import("process");
3696
- return await loadConfig32({
3697
- name: nameOrOptions,
3698
- cwd: cwd(),
3699
- generatedDir: "./generated",
3700
- configDir: "./config",
3701
- defaultConfig: {},
3702
- checkEnv: true
3703
- });
3704
- }
3705
- return await loadConfig32(nameOrOptions);
3706
- }
3707
3694
  async function tryLoadConfig22(configPath, defaultConfig22) {
3708
3695
  if (!existsSync3(configPath))
3709
3696
  return null;
@@ -3738,7 +3725,7 @@ function applyEnvVarsToConfig(name, config3, verbose = false) {
3738
3725
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
3739
3726
  result2[key] = processObject(value, envPath);
3740
3727
  } else {
3741
- const envValue = process8.env[envKey] || process8.env[oldEnvKey];
3728
+ const envValue = process6.env[envKey] || process6.env[oldEnvKey];
3742
3729
  if (envValue !== undefined) {
3743
3730
  if (verbose) {
3744
3731
  log.info(`Using environment variable ${envValue ? envKey : oldEnvKey} for config ${name}.${envPath.join(".")}`);
@@ -3777,7 +3764,7 @@ async function loadConfig32({
3777
3764
  checkEnv = true
3778
3765
  }) {
3779
3766
  const configWithEnvVars = checkEnv && typeof defaultConfig22 === "object" && defaultConfig22 !== null && !Array.isArray(defaultConfig22) ? applyEnvVarsToConfig(name, defaultConfig22, verbose) : defaultConfig22;
3780
- const baseDir = cwd || process8.cwd();
3767
+ const baseDir = cwd || process6.cwd();
3781
3768
  const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
3782
3769
  if (verbose) {
3783
3770
  log.info(`Loading configuration for "${name}"${alias ? ` (alias: "${alias}")` : ""} from ${baseDir}`);
@@ -3805,6 +3792,28 @@ async function loadConfig32({
3805
3792
  }
3806
3793
  }
3807
3794
  }
3795
+ if (name) {
3796
+ const homeConfigDir = resolve3(homedir(), ".config", name);
3797
+ const homeConfigPatterns = ["config", `${name}.config`];
3798
+ if (alias) {
3799
+ homeConfigPatterns.push(`${alias}.config`);
3800
+ }
3801
+ if (verbose) {
3802
+ log.info(`Checking user config directory: ${homeConfigDir}`);
3803
+ }
3804
+ for (const configPath of homeConfigPatterns) {
3805
+ for (const ext of extensions) {
3806
+ const fullPath = resolve3(homeConfigDir, `${configPath}${ext}`);
3807
+ const config3 = await tryLoadConfig22(fullPath, configWithEnvVars);
3808
+ if (config3 !== null) {
3809
+ if (verbose) {
3810
+ log.success(`Configuration loaded from user config directory: ${fullPath}`);
3811
+ }
3812
+ return config3;
3813
+ }
3814
+ }
3815
+ }
3816
+ }
3808
3817
  try {
3809
3818
  const pkgPath = resolve3(baseDir, "package.json");
3810
3819
  if (existsSync3(pkgPath)) {
@@ -3839,8 +3848,8 @@ async function loadConfig32({
3839
3848
  }
3840
3849
  return configWithEnvVars;
3841
3850
  }
3842
- var defaultConfigDir22 = resolve3(process8.cwd(), "config");
3843
- var defaultGeneratedDir22 = resolve3(process8.cwd(), "src/generated");
3851
+ var defaultConfigDir22 = resolve3(process6.cwd(), "config");
3852
+ var defaultGeneratedDir22 = resolve3(process6.cwd(), "src/generated");
3844
3853
 
3845
3854
  // git-hooks.config.ts
3846
3855
  var config3 = {
@@ -3858,7 +3867,7 @@ var config3 = {
3858
3867
  var git_hooks_config_default = config3;
3859
3868
 
3860
3869
  // src/config.ts
3861
- var config4 = await config22({
3870
+ var config4 = await loadConfig32({
3862
3871
  name: "git-hooks",
3863
3872
  cwd: process9.cwd(),
3864
3873
  defaultConfig: git_hooks_config_default
@@ -3914,7 +3923,7 @@ if [ -f "$BUN_GIT_HOOKS_RC" ]; then
3914
3923
  fi
3915
3924
 
3916
3925
  `;
3917
- function getGitProjectRoot(directory = process11.cwd()) {
3926
+ function getGitProjectRoot(directory = process10.cwd()) {
3918
3927
  if (directory.endsWith(".git")) {
3919
3928
  return path.normalize(directory);
3920
3929
  }
@@ -3945,7 +3954,7 @@ function getGitProjectRoot(directory = process11.cwd()) {
3945
3954
  }
3946
3955
  return getGitProjectRoot(parentDir);
3947
3956
  }
3948
- function setHooksFromConfig(projectRootPath = process11.cwd(), options) {
3957
+ function setHooksFromConfig(projectRootPath = process10.cwd(), options) {
3949
3958
  if (!config4 || Object.keys(config4).length === 0)
3950
3959
  throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,json}` or `git-hooks.config.{ts,js,mjs,cjs,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
3951
3960
  const configFile = options?.configFile || { ...config4 };
@@ -3967,7 +3976,7 @@ function setHooksFromConfig(projectRootPath = process11.cwd(), options) {
3967
3976
  }
3968
3977
  }
3969
3978
  }
3970
- async function getStagedFiles(projectRoot = process11.cwd()) {
3979
+ async function getStagedFiles(projectRoot = process10.cwd()) {
3971
3980
  try {
3972
3981
  const { stdout } = await execAsync("git diff --cached --name-only --diff-filter=ACMR", { cwd: projectRoot });
3973
3982
  const files = stdout.trim().split(`
@@ -4017,7 +4026,7 @@ function filterFilesByPattern(files, pattern) {
4017
4026
  return isIncluded && !isExcluded;
4018
4027
  });
4019
4028
  }
4020
- async function runCommandOnStagedFiles(command, files, projectRoot = process11.cwd(), verbose = false) {
4029
+ async function runCommandOnStagedFiles(command, files, projectRoot = process10.cwd(), verbose = false) {
4021
4030
  if (files.length === 0) {
4022
4031
  if (verbose)
4023
4032
  console.info("[INFO] No matching files for pattern");
@@ -4069,7 +4078,7 @@ async function processStagedLint(stagedLintConfig, projectRoot, verbose = false)
4069
4078
  }
4070
4079
  return success;
4071
4080
  }
4072
- function _setHook(hook, commandOrConfig, projectRoot = process11.cwd()) {
4081
+ function _setHook(hook, commandOrConfig, projectRoot = process10.cwd()) {
4073
4082
  const gitRoot = getGitProjectRoot(projectRoot);
4074
4083
  if (!gitRoot) {
4075
4084
  console.info("[INFO] No `.git` root folder found, skipping");
@@ -4093,11 +4102,11 @@ function _setHook(hook, commandOrConfig, projectRoot = process11.cwd()) {
4093
4102
  log2.debug(`${addOrModify} ${italic(hook)} hook`);
4094
4103
  fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
4095
4104
  }
4096
- function removeHooks(projectRoot = process11.cwd(), verbose = false) {
4105
+ function removeHooks(projectRoot = process10.cwd(), verbose = false) {
4097
4106
  for (const configEntry of VALID_GIT_HOOKS)
4098
4107
  _removeHook(configEntry, projectRoot, verbose);
4099
4108
  }
4100
- function _removeHook(hook, projectRoot = process11.cwd(), verbose = false) {
4109
+ function _removeHook(hook, projectRoot = process10.cwd(), verbose = false) {
4101
4110
  const gitRoot = getGitProjectRoot(projectRoot);
4102
4111
  const hookPath = path.normalize(`${gitRoot}/hooks/${hook}`);
4103
4112
  if (fs.existsSync(hookPath)) {
@@ -4108,7 +4117,7 @@ function _removeHook(hook, projectRoot = process11.cwd(), verbose = false) {
4108
4117
  log2.success(`Successfully removed the ${hook} hook`);
4109
4118
  }
4110
4119
  async function runStagedLint(hook) {
4111
- const projectRoot = process11.cwd();
4120
+ const projectRoot = process10.cwd();
4112
4121
  const configFile = config4;
4113
4122
  if (!configFile) {
4114
4123
  console.error(`[ERROR] No configuration found`);
@@ -4145,57 +4154,57 @@ var cli = new CAC("git-hooks");
4145
4154
  var log3 = new Logger("git-hooks", {
4146
4155
  showTags: true
4147
4156
  });
4148
- var { SKIP_INSTALL_GIT_HOOKS } = process12.env;
4157
+ var { SKIP_INSTALL_GIT_HOOKS } = process11.env;
4149
4158
  if (["1", "true"].includes(SKIP_INSTALL_GIT_HOOKS || "")) {
4150
4159
  log3.info(`SKIP_INSTALL_GIT_HOOKS is set to "${SKIP_INSTALL_GIT_HOOKS}", skipping installing hooks.`);
4151
- process12.exit(0);
4160
+ process11.exit(0);
4152
4161
  }
4153
4162
  cli.command("[configPath]", "Install git hooks, optionally from specified config file").option("--verbose", "Enable verbose logging").example("git-hooks").example("git-hooks ../src/config.ts").example("git-hooks --verbose").action(async (configPath, options) => {
4154
4163
  try {
4155
4164
  if (options?.verbose) {
4156
4165
  log3.debug(`Config path: ${configPath || "using default"}`);
4157
- log3.debug(`Working directory: ${process12.cwd()}`);
4166
+ log3.debug(`Working directory: ${process11.cwd()}`);
4158
4167
  }
4159
4168
  if (configPath) {
4160
4169
  const config5 = await import(configPath);
4161
- setHooksFromConfig(process12.cwd(), { configFile: config5 });
4170
+ setHooksFromConfig(process11.cwd(), { configFile: config5 });
4162
4171
  } else {
4163
- setHooksFromConfig(process12.cwd());
4172
+ setHooksFromConfig(process11.cwd());
4164
4173
  }
4165
4174
  log3.success("Successfully set all git hooks");
4166
4175
  } catch (err) {
4167
4176
  log3.error(err);
4168
- process12.exit(1);
4177
+ process11.exit(1);
4169
4178
  }
4170
4179
  });
4171
4180
  cli.command("uninstall", "Remove all git hooks").alias("remove").option("--verbose", "Enable verbose logging").example("git-hooks uninstall").example("git-hooks remove").example("git-hooks uninstall --verbose").action(async (options) => {
4172
4181
  try {
4173
4182
  if (options?.verbose) {
4174
- log3.debug(`Removing hooks from: ${process12.cwd()}`);
4183
+ log3.debug(`Removing hooks from: ${process11.cwd()}`);
4175
4184
  }
4176
- removeHooks(process12.cwd(), options?.verbose);
4185
+ removeHooks(process11.cwd(), options?.verbose);
4177
4186
  log3.success("Successfully removed all git hooks");
4178
4187
  } catch (err) {
4179
4188
  log3.error("Was not able to remove git hooks. Error:", err);
4180
- process12.exit(1);
4189
+ process11.exit(1);
4181
4190
  }
4182
4191
  });
4183
4192
  cli.command("run-staged-lint <hook>", "Run staged lint for a specific git hook").option("--verbose", "Enable verbose logging").example("git-hooks run-staged-lint pre-commit").example("git-hooks run-staged-lint pre-push --verbose").action(async (hook, options) => {
4184
4193
  try {
4185
4194
  if (options?.verbose) {
4186
4195
  log3.debug(`Running staged lint for hook: ${hook}`);
4187
- log3.debug(`Working directory: ${process12.cwd()}`);
4196
+ log3.debug(`Working directory: ${process11.cwd()}`);
4188
4197
  }
4189
4198
  const success = await runStagedLint(hook);
4190
4199
  if (success) {
4191
4200
  log3.success("Staged lint completed successfully");
4192
4201
  } else {
4193
4202
  log3.error("Staged lint failed");
4194
- process12.exit(1);
4203
+ process11.exit(1);
4195
4204
  }
4196
4205
  } catch (err) {
4197
4206
  log3.error("Was not able to run staged lint. Error:", err);
4198
- process12.exit(1);
4207
+ process11.exit(1);
4199
4208
  }
4200
4209
  });
4201
4210
  cli.version(version);
package/dist/index.js CHANGED
@@ -18,12 +18,13 @@ var __toESM = (mod, isNodeMode, target) => {
18
18
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
19
 
20
20
  // src/config.ts
21
- import process6 from "node:process";
21
+ import process7 from "node:process";
22
22
 
23
23
  // node_modules/bunfig/dist/index.js
24
24
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readdirSync as readdirSync2, writeFileSync as writeFileSync3 } from "fs";
25
+ import { homedir } from "os";
25
26
  import { dirname as dirname2, resolve as resolve3 } from "path";
26
- import process8 from "process";
27
+ import process6 from "process";
27
28
  import { join, relative, resolve as resolve2 } from "path";
28
29
  import process2 from "process";
29
30
  import { existsSync, mkdirSync, readdirSync, writeFileSync } from "fs";
@@ -1615,20 +1616,6 @@ function isObject2(item) {
1615
1616
  var log = new Logger("bunfig", {
1616
1617
  showTags: true
1617
1618
  });
1618
- async function config2(nameOrOptions = { defaultConfig: {} }) {
1619
- if (typeof nameOrOptions === "string") {
1620
- const { cwd } = await import("process");
1621
- return await loadConfig3({
1622
- name: nameOrOptions,
1623
- cwd: cwd(),
1624
- generatedDir: "./generated",
1625
- configDir: "./config",
1626
- defaultConfig: {},
1627
- checkEnv: true
1628
- });
1629
- }
1630
- return await loadConfig3(nameOrOptions);
1631
- }
1632
1619
  async function tryLoadConfig2(configPath, defaultConfig2) {
1633
1620
  if (!existsSync3(configPath))
1634
1621
  return null;
@@ -1663,7 +1650,7 @@ function applyEnvVarsToConfig(name, config3, verbose = false) {
1663
1650
  if (typeof value === "object" && value !== null && !Array.isArray(value)) {
1664
1651
  result2[key] = processObject(value, envPath);
1665
1652
  } else {
1666
- const envValue = process8.env[envKey] || process8.env[oldEnvKey];
1653
+ const envValue = process6.env[envKey] || process6.env[oldEnvKey];
1667
1654
  if (envValue !== undefined) {
1668
1655
  if (verbose) {
1669
1656
  log.info(`Using environment variable ${envValue ? envKey : oldEnvKey} for config ${name}.${envPath.join(".")}`);
@@ -1702,7 +1689,7 @@ async function loadConfig3({
1702
1689
  checkEnv = true
1703
1690
  }) {
1704
1691
  const configWithEnvVars = checkEnv && typeof defaultConfig2 === "object" && defaultConfig2 !== null && !Array.isArray(defaultConfig2) ? applyEnvVarsToConfig(name, defaultConfig2, verbose) : defaultConfig2;
1705
- const baseDir = cwd || process8.cwd();
1692
+ const baseDir = cwd || process6.cwd();
1706
1693
  const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
1707
1694
  if (verbose) {
1708
1695
  log.info(`Loading configuration for "${name}"${alias ? ` (alias: "${alias}")` : ""} from ${baseDir}`);
@@ -1730,6 +1717,28 @@ async function loadConfig3({
1730
1717
  }
1731
1718
  }
1732
1719
  }
1720
+ if (name) {
1721
+ const homeConfigDir = resolve3(homedir(), ".config", name);
1722
+ const homeConfigPatterns = ["config", `${name}.config`];
1723
+ if (alias) {
1724
+ homeConfigPatterns.push(`${alias}.config`);
1725
+ }
1726
+ if (verbose) {
1727
+ log.info(`Checking user config directory: ${homeConfigDir}`);
1728
+ }
1729
+ for (const configPath of homeConfigPatterns) {
1730
+ for (const ext of extensions) {
1731
+ const fullPath = resolve3(homeConfigDir, `${configPath}${ext}`);
1732
+ const config3 = await tryLoadConfig2(fullPath, configWithEnvVars);
1733
+ if (config3 !== null) {
1734
+ if (verbose) {
1735
+ log.success(`Configuration loaded from user config directory: ${fullPath}`);
1736
+ }
1737
+ return config3;
1738
+ }
1739
+ }
1740
+ }
1741
+ }
1733
1742
  try {
1734
1743
  const pkgPath = resolve3(baseDir, "package.json");
1735
1744
  if (existsSync3(pkgPath)) {
@@ -1764,11 +1773,11 @@ async function loadConfig3({
1764
1773
  }
1765
1774
  return configWithEnvVars;
1766
1775
  }
1767
- var defaultConfigDir2 = resolve3(process8.cwd(), "config");
1768
- var defaultGeneratedDir2 = resolve3(process8.cwd(), "src/generated");
1776
+ var defaultConfigDir2 = resolve3(process6.cwd(), "config");
1777
+ var defaultGeneratedDir2 = resolve3(process6.cwd(), "src/generated");
1769
1778
 
1770
1779
  // git-hooks.config.ts
1771
- var config3 = {
1780
+ var config2 = {
1772
1781
  "pre-commit": {
1773
1782
  "staged-lint": {
1774
1783
  "**/*.{js,ts}": [
@@ -1780,18 +1789,18 @@ var config3 = {
1780
1789
  "commit-msg": "bunx gitlint .git/COMMIT_EDITMSG",
1781
1790
  verbose: true
1782
1791
  };
1783
- var git_hooks_config_default = config3;
1792
+ var git_hooks_config_default = config2;
1784
1793
 
1785
1794
  // src/config.ts
1786
- var config5 = await config2({
1795
+ var config3 = await loadConfig3({
1787
1796
  name: "git-hooks",
1788
- cwd: process6.cwd(),
1797
+ cwd: process7.cwd(),
1789
1798
  defaultConfig: git_hooks_config_default
1790
1799
  });
1791
1800
  // src/git-hooks.ts
1792
1801
  import fs from "node:fs";
1793
1802
  import path from "node:path";
1794
- import process11 from "node:process";
1803
+ import process10 from "node:process";
1795
1804
  import { exec } from "node:child_process";
1796
1805
  import { promisify } from "node:util";
1797
1806
 
@@ -2037,7 +2046,7 @@ async function loadConfig22() {
2037
2046
  return defaultConfig2;
2038
2047
  }
2039
2048
  }
2040
- var config6 = await loadConfig22();
2049
+ var config4 = await loadConfig22();
2041
2050
  function isBrowserProcess2() {
2042
2051
  if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
2043
2052
  return false;
@@ -2171,7 +2180,7 @@ class Logger2 {
2171
2180
  activeProgressBar = null;
2172
2181
  constructor(name, options = {}) {
2173
2182
  this.name = name;
2174
- this.config = { ...config6 };
2183
+ this.config = { ...config4 };
2175
2184
  this.options = this.normalizeOptions(options);
2176
2185
  this.formatter = this.options.formatter || new JsonFormatter2;
2177
2186
  this.enabled = options.enabled ?? true;
@@ -2227,7 +2236,7 @@ class Logger2 {
2227
2236
  const defaultOptions = {
2228
2237
  format: "json",
2229
2238
  level: "info",
2230
- logDirectory: config6.logDirectory,
2239
+ logDirectory: config4.logDirectory,
2231
2240
  rotation: undefined,
2232
2241
  timestamp: undefined,
2233
2242
  fingersCrossed: {},
@@ -3307,7 +3316,7 @@ if [ -f "$BUN_GIT_HOOKS_RC" ]; then
3307
3316
  fi
3308
3317
 
3309
3318
  `;
3310
- function getGitProjectRoot(directory = process11.cwd()) {
3319
+ function getGitProjectRoot(directory = process10.cwd()) {
3311
3320
  if (directory.endsWith(".git")) {
3312
3321
  return path.normalize(directory);
3313
3322
  }
@@ -3369,7 +3378,7 @@ function checkBunGitHooksInDependencies(projectRootPath) {
3369
3378
  }
3370
3379
  return "bun-git-hooks" in packageJsonContent.devDependencies;
3371
3380
  }
3372
- function _getPackageJson(projectPath = process11.cwd()) {
3381
+ function _getPackageJson(projectPath = process10.cwd()) {
3373
3382
  if (typeof projectPath !== "string") {
3374
3383
  throw new TypeError("projectPath is not a string");
3375
3384
  }
@@ -3380,10 +3389,10 @@ function _getPackageJson(projectPath = process11.cwd()) {
3380
3389
  const packageJsonDataRaw = fs.readFileSync(targetPackageJson, { encoding: "utf-8" });
3381
3390
  return { packageJsonContent: JSON.parse(packageJsonDataRaw), packageJsonPath: targetPackageJson };
3382
3391
  }
3383
- function setHooksFromConfig(projectRootPath = process11.cwd(), options) {
3384
- if (!config5 || Object.keys(config5).length === 0)
3392
+ function setHooksFromConfig(projectRootPath = process10.cwd(), options) {
3393
+ if (!config3 || Object.keys(config3).length === 0)
3385
3394
  throw new Error("[ERROR] Config was not found! Please add `.git-hooks.config.{ts,js,mjs,cjs,json}` or `git-hooks.config.{ts,js,mjs,cjs,json}` or the `git-hooks` entry in package.json.\r\nCheck README for details");
3386
- const configFile = options?.configFile || { ...config5 };
3395
+ const configFile = options?.configFile || { ...config3 };
3387
3396
  _validateStagedLintConfig(configFile);
3388
3397
  const hookKeys = Object.keys(configFile).filter((key) => !VALID_OPTIONS.includes(key));
3389
3398
  const isValidConfig = hookKeys.every((key) => VALID_GIT_HOOKS.includes(key));
@@ -3402,12 +3411,12 @@ function setHooksFromConfig(projectRootPath = process11.cwd(), options) {
3402
3411
  }
3403
3412
  }
3404
3413
  }
3405
- async function getStagedFiles(projectRoot = process11.cwd()) {
3414
+ async function getStagedFiles(projectRoot = process10.cwd()) {
3406
3415
  try {
3407
3416
  const { stdout } = await execAsync("git diff --cached --name-only --diff-filter=ACMR", { cwd: projectRoot });
3408
3417
  const files = stdout.trim().split(`
3409
3418
  `).filter(Boolean);
3410
- if (config5.verbose && files.length > 0) {
3419
+ if (config3.verbose && files.length > 0) {
3411
3420
  console.info("[INFO] Staged files found:", files);
3412
3421
  }
3413
3422
  return files;
@@ -3452,7 +3461,7 @@ function filterFilesByPattern(files, pattern) {
3452
3461
  return isIncluded && !isExcluded;
3453
3462
  });
3454
3463
  }
3455
- async function runCommandOnStagedFiles(command, files, projectRoot = process11.cwd(), verbose = false) {
3464
+ async function runCommandOnStagedFiles(command, files, projectRoot = process10.cwd(), verbose = false) {
3456
3465
  if (files.length === 0) {
3457
3466
  if (verbose)
3458
3467
  console.info("[INFO] No matching files for pattern");
@@ -3504,7 +3513,7 @@ async function processStagedLint(stagedLintConfig, projectRoot, verbose = false)
3504
3513
  }
3505
3514
  return success;
3506
3515
  }
3507
- function _setHook(hook, commandOrConfig, projectRoot = process11.cwd()) {
3516
+ function _setHook(hook, commandOrConfig, projectRoot = process10.cwd()) {
3508
3517
  const gitRoot = getGitProjectRoot(projectRoot);
3509
3518
  if (!gitRoot) {
3510
3519
  console.info("[INFO] No `.git` root folder found, skipping");
@@ -3528,11 +3537,11 @@ function _setHook(hook, commandOrConfig, projectRoot = process11.cwd()) {
3528
3537
  log2.debug(`${addOrModify} ${italic2(hook)} hook`);
3529
3538
  fs.writeFileSync(hookPath, hookCommand, { mode: 493 });
3530
3539
  }
3531
- function removeHooks(projectRoot = process11.cwd(), verbose = false) {
3540
+ function removeHooks(projectRoot = process10.cwd(), verbose = false) {
3532
3541
  for (const configEntry of VALID_GIT_HOOKS)
3533
3542
  _removeHook(configEntry, projectRoot, verbose);
3534
3543
  }
3535
- function _removeHook(hook, projectRoot = process11.cwd(), verbose = false) {
3544
+ function _removeHook(hook, projectRoot = process10.cwd(), verbose = false) {
3536
3545
  const gitRoot = getGitProjectRoot(projectRoot);
3537
3546
  const hookPath = path.normalize(`${gitRoot}/hooks/${hook}`);
3538
3547
  if (fs.existsSync(hookPath)) {
@@ -3543,8 +3552,8 @@ function _removeHook(hook, projectRoot = process11.cwd(), verbose = false) {
3543
3552
  log2.success(`Successfully removed the ${hook} hook`);
3544
3553
  }
3545
3554
  async function runStagedLint(hook) {
3546
- const projectRoot = process11.cwd();
3547
- const configFile = config5;
3555
+ const projectRoot = process10.cwd();
3556
+ const configFile = config3;
3548
3557
  if (!configFile) {
3549
3558
  console.error(`[ERROR] No configuration found`);
3550
3559
  return false;
@@ -3564,10 +3573,10 @@ async function runStagedLint(hook) {
3564
3573
  console.error(`[ERROR] No staged lint configuration found for hook ${hook}`);
3565
3574
  return false;
3566
3575
  }
3567
- function _validateStagedLintConfig(config4) {
3576
+ function _validateStagedLintConfig(config5) {
3568
3577
  for (const hook of VALID_GIT_HOOKS) {
3569
- if (hook !== "pre-commit" && config4[hook] && typeof config4[hook] === "object") {
3570
- const hookConfig = config4[hook];
3578
+ if (hook !== "pre-commit" && config5[hook] && typeof config5[hook] === "object") {
3579
+ const hookConfig = config5[hook];
3571
3580
  if (hookConfig["stagedLint"] || hookConfig["staged-lint"]) {
3572
3581
  throw new Error(`staged-lint is only allowed in pre-commit hook. Found in ${hook} hook.`);
3573
3582
  }
@@ -3580,7 +3589,7 @@ export {
3580
3589
  removeHooks,
3581
3590
  getProjectRootDirectoryFromNodeModules,
3582
3591
  getGitProjectRoot,
3583
- config5 as config,
3592
+ config3 as config,
3584
3593
  checkBunGitHooksInDependencies,
3585
3594
  VALID_OPTIONS,
3586
3595
  VALID_GIT_HOOKS,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-git-hooks",
3
3
  "type": "module",
4
- "version": "0.2.18",
4
+ "version": "0.2.19",
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",
@@ -77,12 +77,12 @@
77
77
  "@stacksjs/docs": "^0.70.23",
78
78
  "@stacksjs/eslint-config": "^4.10.2-beta.3",
79
79
  "@stacksjs/gitlint": "^0.1.5",
80
- "@types/bun": "^1.2.17",
80
+ "@types/bun": "^1.2.19",
81
81
  "bumpp": "^10.2.0",
82
82
  "bun-plugin-dtsx": "^0.21.12",
83
- "bunfig": "^0.10.0",
83
+ "bunfig": "^0.10.1",
84
84
  "cac": "^6.7.14",
85
- "changelogen": "^0.6.1",
85
+ "changelogen": "^0.6.2",
86
86
  "typescript": "^5.8.3"
87
87
  },
88
88
  "overrides": {