Sha256: 24f76cdd71c3f63f9a5b420ad26dbc001a13c6a0d06c141d20eac14db2613cb0

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
module Phare
  class Check
    class JSCS < Check
      attr_reader :config, :path

      def initialize(directory, options = {})
        @config = File.expand_path("#{directory}.jscs.json", __FILE__)
        @path = File.expand_path("#{directory}app/assets", __FILE__)
        @extensions = %w(.js)
        @options = options

        super
      end

      def command
        if @tree.changed?
          "jscs #{@tree.changes.join(' ')}"
        else
          "jscs #{@path}"
        end
      end

    protected

      def binary_exists?
        !Phare.system_output('which jscs').empty?
      end

      def configuration_exists?
        File.exists?(@config)
      end

      def argument_exists?
        @tree.changed? || Dir.exists?(@path)
      end

      def print_banner
        Phare.puts '---------------------------------------------'
        Phare.puts 'Running JSCS to check for JavaScript style…'
        Phare.puts '---------------------------------------------'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phare-0.5.2 lib/phare/check/jscs.rb
phare-0.5.1 lib/phare/check/jscs.rb