class Overcommit::Hook::PreCommit::NginxTest

Runs `nginx -t` against any modified Nginx config files.

@see www.nginx.com/resources/wiki/start/topics/tutorials/commandline/

Constants

MESSAGE_REGEX

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/nginx_test.rb, line 10
def run
  messages = []

  applicable_files.each do |file|
    result = execute(command + ['-c', file])
    next if result.success?

    messages += extract_messages(
      result.stderr.split("\n").grep(MESSAGE_REGEX),
      MESSAGE_REGEX
    )
  end

  messages
end