From 6ffce57bb48e93ce6a04f5790e3e2ed3aadb163e Mon Sep 17 00:00:00 2001 From: servius Date: Mon, 11 May 2026 07:02:43 +0530 Subject: [PATCH] fix: Use -U on ast-grep if just add triggered from script --- justfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/justfile b/justfile index f76f24f..a3e7cb6 100644 --- a/justfile +++ b/justfile @@ -52,7 +52,8 @@ add path name: echo '{...}: { }' > "$dir/{{name}}.nix" # https://ast-grep.github.io/advanced/pattern-parse.html#incomplete-pattern-code # Since the imports doesn't match the whole pattern we need to use the selector binding and the attr expression to match it properly. - ast-grep run -p '{ imports = [$$$ITEMS] }' --selector binding --rewrite 'imports = [$$$ITEMS ./{{name}}.nix ]' "$dir/default.nix" -i + if [ -t 0 ] && [ -t 1 ]; then sg_flag=-i; else sg_flag=-U; fi + ast-grep run -p '{ imports = [$$$ITEMS] }' --selector binding --rewrite 'imports = [$$$ITEMS ./{{name}}.nix ]' "$dir/default.nix" "$sg_flag" alejandra fmt "$dir/{{name}}.nix" "$dir/default.nix" git add "$dir/{{name}}.nix" -- 2.51.2