Skip to content

Commit 4924de7

Browse files
author
Roman Gonzalez
committed
refact: add mkCmdArgs function
Add utility function on the hooks file to allow easy creation of command args given a predicate.
1 parent 6671dda commit 4924de7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

modules/hooks.nix

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ let
77
lib.optionalString
88
(settings.rust.cargoManifestPath != null)
99
"--manifest-path ${lib.escapeShellArg settings.rust.cargoManifestPath}";
10+
11+
mkCmdArgs = predActionList:
12+
lib.concatStringsSep
13+
" "
14+
(builtins.foldl'
15+
(acc: entry:
16+
acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1))
17+
[ ]
18+
predActionList);
19+
1020
in
1121
{
1222
options.settings =
@@ -837,16 +847,10 @@ in
837847
entry =
838848
let
839849
cmdArgs =
840-
lib.concatStringsSep
841-
" "
842-
(builtins.concatLists [
843-
[ "-set_exit_status" ]
844-
(if settings.revive.configPath != "" then
845-
[ "-config ${settings.revive.configPath}" ]
846-
else
847-
[ ])
848-
]
849-
);
850+
mkCmdArgs [
851+
[ true "-set_exit_status" ]
852+
[ (settings.revive.configPath != "") "-config ${settings.revive.configPath}" ]
853+
];
850854
# revive works with both files and directories; however some lints
851855
# may fail (e.g. package-comment) if they run on an individual file
852856
# rather than a package/directory scope; given this let's get the

0 commit comments

Comments
 (0)