class Overcommit::Hook::PreCommit::Standard

Runs ‘standard` against any modified JavaScript files.

@see github.com/feross/standard

Constants

MESSAGE_REGEX

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/standard.rb, line 10
def run
  result = execute(command, args: applicable_files)
  output = result.stdout.chomp
  return :pass if result.success? && output.empty?

  # example message:
  #   path/to/file.js:1:1: Error message (ruleName)
  extract_messages(
    output.split("\n").grep(MESSAGE_REGEX), # ignore header line
    MESSAGE_REGEX
  )
end