Sha256: 38206df3bb2a025b03ae73c4f7a0750f3e731201176e05615b9e538c0dcc1ea4

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

module Phare
  module Checks
    class JavaScriptJSHint
      attr_reader :status

      def initialize(directory)
        @config = File.expand_path("#{directory}.jshintrc", __FILE__)
        @path = File.expand_path("#{directory}app/assets/javascripts/**/*", __FILE__)
        @command = "jshint --config #{@config} --extra-ext .js,.es6.js #{@path}"

        puts '---------------------------------------------'
        puts 'Running JSHint to check for JavaScript style…'
        puts '---------------------------------------------'
      end

      def run
        if File.exists?(@config)
          system(@command)
          @status = $CHILD_STATUS.exitstatus

          if @status == 0
            puts 'No code style errors found.'
          else
            puts "Something went wrong. Program exited with #{@status}"
          end
        else
          puts 'No `.jshintrc` configuration file found. Skipping it.'
          @status = 0
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phare-0.1 lib/phare/checks/javascript_jshint.rb