Sha256: 27ced8aeb2c3f5d085257ee97e0bf5e19fa3a6e5b61bc703235623d4a5379660

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

require 'json'

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 #{files_to_check.join(' ')}"
        else
          "jscs #{@path}"
        end
      end

    protected

      def excluded_list
        configuration_file['excludeFiles']
      end

      def configuration_file
        @configuration_file ||= File.exist?('.jscs.json') ? JSON.parse(File.read('.jscs.json')) : {}
      end

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phare-0.7.1 lib/phare/check/jscs.rb
phare-0.7 lib/phare/check/jscs.rb