Class: Guard::Eslint::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/eslint/runner.rb

Overview

This class runs ‘eslint` command, retrieves result and notifies. An instance of this class is intended to invoke `eslint` only once in its lifetime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



11
12
13
# File 'lib/guard/eslint/runner.rb', line 11

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/guard/eslint/runner.rb', line 15

def options
  @options
end

Instance Method Details

#failed_pathsObject



33
34
35
# File 'lib/guard/eslint/runner.rb', line 33

def failed_paths
  result.reject { |f| f[:messages].empty? }.map { |f| f[:filePath] }
end

#run(paths) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/guard/eslint/runner.rb', line 17

def run(paths)
  paths = options[:default_paths] unless paths

  passed = run_for_check(paths)
  case options[:notification]
  when :failed
    notify(passed) unless passed
  when true
    notify(passed)
  end

  run_for_output(paths)

  passed
end