Skip to content

Commit

Permalink
feat(back): #1332 add check flag to nixfmt
Browse files Browse the repository at this point in the history
- Run check only in CI, locally it will format the code
- Update docs to show the use of nixfmt
instead of Alejandra

Signed-off-by: Robin Quintero <rohaquinlop301@gmail.com>
  • Loading branch information
rohaquinlop committed Jun 24, 2024
1 parent dcb3432 commit f026919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/src/api/builtins/format.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Example:
## formatNix

Ensure that Nix code is formatted
according to [Alejandra](https://github.com/kamadorueda/alejandra).
according to [nixfmt](https://github.com/NixOS/nixfmt).

Types:

Expand Down
6 changes: 5 additions & 1 deletion src/args/format-nix/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

function main {
source __argTargets__/template local targets
local args=()

info Formatting Nix code \
&& if running_in_ci_cd_provider; then
args+=(--check)
fi \
&& for target in "${targets[@]}"; do
info Formatting "${target}" \
&& if ! nixfmt "${target}"; then
&& if ! nixfmt "${args[@]}" "${target}"; then
info Source code was formated, the job will fail \
&& error Failing as promised...
fi \
Expand Down

0 comments on commit f026919

Please sign in to comment.