guard-eslint 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 412149b9e2b0bb334b7a0b846798e89ffff0ba0ff8b659709090ebf62f662614
4
- data.tar.gz: 56e68082416044e808baadecbb89007da39fdcf9b1fe9045b1cbae59838803fe
3
+ metadata.gz: 8f20264724f2f4b7133396fc8e73bc9ebc150a127d3f82bead737c075e4b5c2e
4
+ data.tar.gz: 04fcb34297e9753634bb5c0a11029f511933956d8c540c92f2ae2eeeed7f983e
5
5
  SHA512:
6
- metadata.gz: 9f1c8f469ba5a39050087754d1b4a54d26784e09159601f76003b2049d02507507152a6455227b20730c1a575ab1489e8ae87e3dc74d237ffb89e9d3ea8e157e
7
- data.tar.gz: 7e6ebd38246b03568668508a4928db058160f268a1b92b8d17d9890e65a39df685604da475a298f0b750b0aa76385b589f73fee6e22d9d49fbb5c2e28c1d285b
6
+ metadata.gz: 54b494ed2e31947f3716bd2f1267dfd0de5751690faa6432c57a14abab2e11b3d5ab8352716c302c01f1bae8fe9f46a4e1b98ac7b21d05604b927c4c80bbee67
7
+ data.tar.gz: 7e57aa358ebd26eaeee890a2f33aec48dd06c9e5556c2243510246f4a072f34102a91b04d4e8581e590a3ec4519b31c4232be22055a8282b7fa5422710130a22
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'json'
4
+ require 'open3'
4
5
 
5
6
  module Guard
6
7
  class Eslint
@@ -16,8 +17,7 @@ module Guard
16
17
  def run(paths)
17
18
  paths = options[:default_paths] unless paths
18
19
 
19
- command = command_for_check(paths)
20
- passed = system(*command)
20
+ passed = run_for_check(paths)
21
21
  case options[:notification]
22
22
  when :failed
23
23
  notify(passed) unless passed
@@ -30,6 +30,24 @@ module Guard
30
30
  passed
31
31
  end
32
32
 
33
+ def failed_paths
34
+ result.reject { |f| f[:messages].empty? }.map { |f| f[:filePath] }
35
+ end
36
+
37
+ private
38
+
39
+ attr_accessor :check_stdout, :check_stderr
40
+
41
+ def run_for_check(paths)
42
+ command = command_for_check(paths)
43
+ (stdout, stderr, status) = Open3.capture3(*command)
44
+ self.check_stdout = stdout
45
+ self.check_stderr = stderr
46
+ status
47
+ rescue SystemCallError => e
48
+ fail "The eslint command failed with #{e.message}: `#{command}`"
49
+ end
50
+
33
51
  ##
34
52
  # Once eslint reports a failure, we have to run it again to show the results using the
35
53
  # formatter that it uses for output.
@@ -87,6 +105,8 @@ module Guard
87
105
  JSON.parse(file.read, symbolize_names: true)
88
106
  end
89
107
  end
108
+ rescue JSON::ParserError
109
+ fail "eslint JSON output could not be parsed. Output from eslint was:\n#{check_stderr}\n#{check_stdout}"
90
110
  end
91
111
 
92
112
  def notify(passed)
@@ -115,10 +135,6 @@ module Guard
115
135
  end
116
136
  # rubocop:enable Metric/AbcSize
117
137
 
118
- def failed_paths
119
- result.reject { |f| f[:messages].empty? }.map { |f| f[:filePath] }
120
- end
121
-
122
138
  def pluralize(number, thing, options = {})
123
139
  text = ''
124
140
 
@@ -4,8 +4,8 @@ module Guard
4
4
  module EslintVersion
5
5
  # http://semver.org/
6
6
  MAJOR = 1
7
- MINOR = 0
8
- PATCH = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
9
 
10
10
  def self.to_s
11
11
  [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-eslint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tadiou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-11-16 00:00:00.000000000 Z
12
+ date: 2018-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard