From d70a0f569da2cb87901d1d0ef417ad35178f360d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sj=C3=B6berg?= Date: Sat, 13 Mar 2021 13:35:56 +0100 Subject: [PATCH] Cleanup fmt command Instead of creating a temporary file, we can just tell Zig to read the input from stdin. --- Commands/Fmt.tmCommand | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Commands/Fmt.tmCommand b/Commands/Fmt.tmCommand index 2520d2b..d4a60d5 100644 --- a/Commands/Fmt.tmCommand +++ b/Commands/Fmt.tmCommand @@ -10,21 +10,11 @@ # shellcheck source=/dev/null . "${TM_SUPPORT_PATH}/lib/bash_init.sh" -set -e +set -e -PATH=/opt/local/bin:/usr/local/bin:/usr/local/zig/bin:$PATH - -require_cmd zig +require_cmd "${TM_ZIG:-zig}" -tmpfile=$(mktemp "${TMPDIR:-/tmp/}zig-fmt.XXXXXX") -cat - > "$tmpfile" - -if ! error=$("${TM_ZIG:-zig}" fmt "$tmpfile" 2>&1);then - exit_show_tool_tip "${error//$tmpfile/$(basename "$TM_FILEPATH")}" -fi - -cat "$tmpfile" -rm "$tmpfile" +(eval "${TM_ZIG:-zig} fmt --stdin") || exit_show_tool_tip input document