git-hooks.nix icon indicating copy to clipboard operation
git-hooks.nix copied to clipboard

Option to allow passing absolute file paths

Open Alexnortung opened this issue 2 years ago • 1 comments

currently we have the pass_filenames, but in certain cases it would be nice if the passed file names could be absolute paths.

Use case: We have a monorepo with multiple projects that use prettier. If we use the predefined prettier hook, then it would not recognize the plugins that have been enabled prettier since they are installed in the node_modules folder in a nested folder. So I tried creating a custom hook, but then the file names would be something like project/file-to-format instead of just file-to-format or /absolute/path/project/file-to-format.

pre-commit.hooks = {
  # prettier.enable = true;
  prettier-nextjs = {
    enable = true;
    name = "Prettier Next.js";
    files = "nextjs\/*";
    entry = "${pnpm}/bin/pnpm --dir nextjs exec prettier --write";
  };
};

In my case if the files could have an absolute path instead of a relative one it would solve my issue.

Alexnortung avatar Sep 14 '23 15:09 Alexnortung

Upstream issue: https://github.com/pre-commit/pre-commit/issues/2621

sandydoo avatar May 02 '24 22:05 sandydoo