class Overcommit::Hook::PreCommit::Jsl

Runs `jsl` against any modified JavaScript files.

@see www.javascriptlint.com/

Constants

MESSAGE_REGEX
MESSAGE_TYPE_CATEGORIZER

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/jsl.rb, line 14
def run
  file_flags = applicable_files.map { |file| ['-process', file] }
  result = execute(command + file_flags.flatten)
  return :pass if result.success?

  # example message:
  #   path/to/file.js(1): lint warning: Error message
  extract_messages(
    result.stdout.split("\n").grep(MESSAGE_REGEX),
    MESSAGE_REGEX,
    MESSAGE_TYPE_CATEGORIZER
  )
end