guard-jest_runner 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1847de557f71cf8d145bdf4f0b19054c01481070f0e8c1ecca65d0cdb8191fc
4
- data.tar.gz: a580e164831f24e9a8c865aa9e5aa2bcc8902d78cab70ae2e56e39f3761b8dc0
3
+ metadata.gz: ff2469e473ee045db09982d7bdc7d161183d91976bcbac6348a09bfa6cd90715
4
+ data.tar.gz: 7307d43a3cc4cdcb22d667bb42878a7037371d8a72d145b440eeb69a6340d84d
5
5
  SHA512:
6
- metadata.gz: 1829c01972e0bda7e10bfb1813b85dd0b355942723a026cf146d9755f79c7c5df7423a198c782f9bf0ec02b505fe5610c01688755a3b3002cb4f851fe32e677e
7
- data.tar.gz: 8d5dd3199ec048465e64c5d837d139f223ff05726f383f52f72d42c681d9d86fdc771c83bfe3330c533d1567157f6ea223d1c273b79893507d3f18845c99ca45
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
- 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
@@ -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
 
@@ -6,7 +6,7 @@ module Guard
6
6
  module JestRunnerVersion
7
7
  # http://semver.org/
8
8
  MAJOR = 1
9
- MINOR = 0
9
+ MINOR = 1
10
10
  PATCH = 0
11
11
 
12
12
  def self.to_s
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.0.0
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-16 00:00:00.000000000 Z
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard