Sha256: 7a5aa72e97b5260a53cdc581fccc23be219dc661f41d291e1e23a3387fe33d48

Contents?: true

Size: 961 Bytes

Versions: 3

Compression:

Stored size: 961 Bytes

Contents

module Phare
  module Checks
    class JavaScriptJSCS
      attr_reader :status

      def initialize(directory)
        @config = File.expand_path("#{directory}.jscs.json", __FILE__)
        @path = File.expand_path("#{directory}app/assets", __FILE__)
        @command = "jscs #{@path}"
      end

      def run
        if should_run?
          print_banner
          system(@command)
          @status = $CHILD_STATUS.exitstatus

          unless @status == 0
            puts "Something went wrong. Program exited with #{@status}"
          end

          puts ''
        else
          @status = 0
        end
      end

    protected

      def should_run?
        !`which jscs`.empty? && File.exists?(@config)
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phare-0.2 lib/phare/checks/javascript_jscs.rb
phare-0.1.2 lib/phare/checks/javascript_jscs.rb
phare-0.1.1 lib/phare/checks/javascript_jscs.rb