Sha256: 19249a3d647bdc02479baadd8168a65d830a380c699311326d8102c7e2715407

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'open3'
require 'pre-commit/checks/plugin'

module PreCommit
  module Checks
    # Runs coffeelint against coffeescript files
    class CoffeeLint < Plugin
      def call(staged_files)
        staged_files = staged_files.grep(/\.coffee$/)
        return if staged_files.empty?

        config_flag = ENV['COFFEELINT_CONFIG'] ? "-f #{ENV['COFFEELINT_CONFIG']}" : ''
        args = staged_files.join(' ')

        stdout, stderr, result = Open3.capture3("coffeelint #{config_flag} #{args}")
        stdout + stderr unless result.success?
      end

      def self.description
        'Runs coffeelint to detect errors'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gazelle_styleguide-0.0.1 lib/plugins/pre_commit/checks/coffee_lint.rb