cachix / git-hooks.nix

Seamless integration of https://pre-commit.com git hooks with Nix.
Apache License 2.0
522 stars 155 forks source link

Option to allow passing absolute file paths #354

Open Alexnortung opened 1 year ago

Alexnortung commented 1 year ago

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.

sandydoo commented 5 months ago

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