Skip to content

Commit

Permalink
fix(just): fixes improper formatting of tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed May 27, 2022
1 parent aa68983 commit c64ad25
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
# Create justfile
justConfig = {
tasks = {
fmt = [
"@${tools.nixpkgs-fmt.exe} $(git ls-files **/*.nix)"
"check" = [
"@nix flake check"
];
"fmt flags=''" = [
"@${tools.nixpkgs-fmt.exe} {{ flags }} flake.nix $(git ls-files '**/*.nix')"
];
};
};
Expand Down
1 change: 1 addition & 0 deletions plugins/just/make.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let
files = [ ./template.cue ];
output = ".justfile";
postBuild = ''
cat $out
${pkgs.just}/bin/just --unstable --fmt -f $out
'';
flags = {
Expand Down
20 changes: 14 additions & 6 deletions plugins/just/template.cue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package just

import "strings"
import "text/template"

#Config: {
Expand All @@ -9,15 +10,22 @@ import "text/template"

data: #Config

_final: {
head: data.head
tasks: {
for task, steps in data.tasks {
"\(task)": strings.Join(steps, "\n ")
}
}
}

tmpl:
"""
{{ .head -}}
{{ range $name, $tasks := .tasks -}}
{{ $name -}}:
{{ range $tasks -}}
{{ . }}
{{ end }}
{{ range $name, $steps := .tasks }}
{{ $name }}:
{{ $steps }}
{{- end }}
"""

rendered: template.Execute(tmpl, data)
rendered: template.Execute(tmpl, _final)

0 comments on commit c64ad25

Please sign in to comment.