guard-jest_runner 1.0.0 → 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/jest_runner/runner.rb +22 -6
- data/lib/guard/jest_runner/version.rb +1 -1
- 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: ff2469e473ee045db09982d7bdc7d161183d91976bcbac6348a09bfa6cd90715
|
4
|
+
data.tar.gz: 7307d43a3cc4cdcb22d667bb42878a7037371d8a72d145b440eeb69a6340d84d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 785f499337ea8043060dc838cdd17935ae66fd56850f09eef81ff78330c10000ad74bd11de5f82e20457943fa22d7c4955d99d3591d8da2f59a577040b224089
|
7
|
+
data.tar.gz: 82bcf598b223c85db928f027ca7d23e8bd9336f80c7e0a01caf97abd83dee1b88b72d01b56cda5b351d686a00b16312e811806bd92e0e159addf1033291df3bc
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'json'
|
4
|
+
require 'open3'
|
4
5
|
|
5
6
|
module Guard
|
6
7
|
class JestRunner
|
@@ -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
|
@@ -28,6 +28,24 @@ module Guard
|
|
28
28
|
passed
|
29
29
|
end
|
30
30
|
|
31
|
+
def failed_paths
|
32
|
+
result[:testResults].select { |f| f[:status] == "failed" }.map { |f| f[:name] }.uniq
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_accessor :check_stdout, :check_stderr
|
38
|
+
|
39
|
+
def run_for_check(paths)
|
40
|
+
command = command_for_check(paths)
|
41
|
+
(stdout, stderr, status) = Open3.capture3(*command)
|
42
|
+
self.check_stdout = stdout
|
43
|
+
self.check_stderr = stderr
|
44
|
+
status
|
45
|
+
rescue SystemCallError => e
|
46
|
+
fail "The jest command failed with #{e.message}: `#{command}`"
|
47
|
+
end
|
48
|
+
|
31
49
|
def command_for_check(paths)
|
32
50
|
command = [options[:command]]
|
33
51
|
|
@@ -72,6 +90,8 @@ module Guard
|
|
72
90
|
JSON.parse(file.read, symbolize_names: true)
|
73
91
|
end
|
74
92
|
end
|
93
|
+
rescue JSON::ParserError
|
94
|
+
fail "jest JSON output could not be parsed. Output from jest was:\n#{check_stderr}\n#{check_stdout}"
|
75
95
|
end
|
76
96
|
|
77
97
|
def notify(passed)
|
@@ -102,10 +122,6 @@ module Guard
|
|
102
122
|
end
|
103
123
|
end
|
104
124
|
|
105
|
-
def failed_paths
|
106
|
-
result[:testResults].select { |f| f[:status] == "failed" }.map { |f| f[:name] }.uniq
|
107
|
-
end
|
108
|
-
|
109
125
|
def pluralize(number, thing, options = {})
|
110
126
|
text = String.new
|
111
127
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jest_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RobinDaugherty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|