From 03c7a142be52a909ceea0adac03071b059cf76a5 Mon Sep 17 00:00:00 2001 From: XuehaiPan Date: Wed, 15 Sep 2021 22:31:56 +0800 Subject: [PATCH] style: add keyward argument `inplace` to run_shfmt --- Library/Homebrew/style.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index b82a2a65ad..7bf80ecdce 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -65,7 +65,7 @@ module Homebrew run_shellcheck(shell_files, output_type) end - run_shfmt(shell_files) if ruby_files.none? || shell_files.any? + run_shfmt(shell_files, inplace: fix) if ruby_files.none? || shell_files.any? if output_type == :json Offenses.new(rubocop_result + shellcheck_result) @@ -214,11 +214,16 @@ module Homebrew end end - def run_shfmt(files) + def run_shfmt(files, inplace: false) files = shell_scripts if files.empty? + # Do not format completions and Dockerfile + files.delete(HOMEBREW_REPOSITORY/"completions/bash/brew") + files.delete(HOMEBREW_REPOSITORY/"Dockerfile") args = ["-i", "2", "-ci", "-ln", "bash", "--", *files] + args.unshift("-w") if inplace + system shfmt, *args $CHILD_STATUS.success? end