Skip to content

Commit f58f1d8

Browse files
committed
Run packer fmt on paths instead of files
It turns out that you can run `packer fmt` on a path and it will check any applicable files if that path is a directory. It makes sense to use that functionality in the packer_fmt hook instead of running it against each individual file.
1 parent 15a2656 commit f58f1d8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hooks/packer_fmt.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ source "$SCRIPT_DIR/../lib/util.sh"
1717

1818
util::parse_cmdline "$@"
1919

20+
util::get_unique_directory_paths "${FILES[@]}"
21+
2022
pids=()
21-
for file in "${FILES[@]}"; do
23+
for path in "${UNIQUE_PATHS[@]}"; do
2224
# Check each path in parallel
2325
{
24-
packer fmt "${ARGS[@]}" -- "$file"
26+
packer fmt "${ARGS[@]}" -- "$path"
2527
} &
2628
pids+=("$!")
2729
done

0 commit comments

Comments
 (0)