Skip to content

Commit

Permalink
yamlfmt: allow formatting during hook run
Browse files Browse the repository at this point in the history
  • Loading branch information
gigamonster256 committed Jan 28, 2025
1 parent 9364dc0 commit 129cb47
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,12 @@ in
default = "";
example = ".yamlfmt";
};
lint-only =
mkOption {
type = types.bool;
description = "Only lint the files, do not format them in place.";
default = true;
};
};
};
};
Expand Down Expand Up @@ -3878,10 +3884,10 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
cmdArgs =
mkCmdArgs
(with hooks.yamlfmt.settings; [
# Exit non-zero on changes
[ true "-lint" ]
# But do not print the diff
[ true "-quiet" ]
# Exit with non-zero status if the file is not formatted
[ lint-only "-lint" ]
# Do not print the diff
[ lint-only "-quiet" ]
# See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery
[ (configPath != "") "-conf ${configPath}" ]
]);
Expand Down

0 comments on commit 129cb47

Please sign in to comment.