Skip to content

Commit 129cb47

Browse files
yamlfmt: allow formatting during hook run
1 parent 9364dc0 commit 129cb47

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

modules/hooks.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,12 @@ in
18751875
default = "";
18761876
example = ".yamlfmt";
18771877
};
1878+
lint-only =
1879+
mkOption {
1880+
type = types.bool;
1881+
description = "Only lint the files, do not format them in place.";
1882+
default = true;
1883+
};
18781884
};
18791885
};
18801886
};
@@ -3878,10 +3884,10 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.ormol
38783884
cmdArgs =
38793885
mkCmdArgs
38803886
(with hooks.yamlfmt.settings; [
3881-
# Exit non-zero on changes
3882-
[ true "-lint" ]
3883-
# But do not print the diff
3884-
[ true "-quiet" ]
3887+
# Exit with non-zero status if the file is not formatted
3888+
[ lint-only "-lint" ]
3889+
# Do not print the diff
3890+
[ lint-only "-quiet" ]
38853891
# See https://github.com/google/yamlfmt/blob/main/docs/config-file.md#config-file-discovery
38863892
[ (configPath != "") "-conf ${configPath}" ]
38873893
]);

0 commit comments

Comments
 (0)