class Overcommit::Hook::PreCommit::MixFormat

Runs ‘mix format –check-formatted` against any modified ex/heex/exs files.

@see hexdocs.pm/mix/main/Mix.Tasks.Format.html

Constants

FILES_REGEX

example message: ** (Mix) mix format failed due to –check-formatted. The following files are not formatted:

* lib/file1.ex
* lib/file2.ex

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/mix_format.rb, line 16
def run
  result = execute(command, args: applicable_files)
  return :pass if result.success?

  result.stderr.scan(FILES_REGEX).flatten.
    map { |file| message(file) }
end

Private Instance Methods

message(file) click to toggle source
# File lib/overcommit/hook/pre_commit/mix_format.rb, line 26
def message(file)
  Overcommit::Hook::Message.new(:error, file, nil, file)
end