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 +4 -4
- data/lib/guard/eslint/runner.rb +22 -6
- data/lib/guard/eslint/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f20264724f2f4b7133396fc8e73bc9ebc150a127d3f82bead737c075e4b5c2e
|
4
|
+
data.tar.gz: 04fcb34297e9753634bb5c0a11029f511933956d8c540c92f2ae2eeeed7f983e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54b494ed2e31947f3716bd2f1267dfd0de5751690faa6432c57a14abab2e11b3d5ab8352716c302c01f1bae8fe9f46a4e1b98ac7b21d05604b927c4c80bbee67
|
7
|
+
data.tar.gz: 7e57aa358ebd26eaeee890a2f33aec48dd06c9e5556c2243510246f4a072f34102a91b04d4e8581e590a3ec4519b31c4232be22055a8282b7fa5422710130a22
|
data/lib/guard/eslint/runner.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/guard/eslint/version.rb
CHANGED
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
|
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-
|
12
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|