helmsnap 0.4.1 → 0.4.2

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: bd784fcd78ea76eeb09743cf411b599c9cd6ab2299a1a647a037d0dcc667cdb0
4
- data.tar.gz: a53928f8100827b1cd738840abff6ab43d875c0d44f5c7400023aa185d5ffeb3
3
+ metadata.gz: 8a5cb05f018581cbbccdfd9114f0ce1426457d63bd4fcd69864d558a6c790be5
4
+ data.tar.gz: c6ff86c42987cbebe2fb71889d05dd0d11e33d0ca164a89419c75b58a6b671ab
5
5
  SHA512:
6
- metadata.gz: 9e5f7c1f7516cf65c9bcb3dde36977e739a5973ec7eaf7147380b797c9acc271b889a637fe6b9d3a6764839ed8362270e77c8160cc0fbcab1aee9775421c7c07
7
- data.tar.gz: 12d305a44dfc9c07956aa84ad5c221a7bf2b404888be7750de6bdcd06617c69d13e9c0a1846e2f07157b029a55b23b867a541014e550f6d94e62989a569494a7
6
+ metadata.gz: 60bf1bbab69d1990b05d93bcc3b22b67318f665d431ea2b770a6eddf894a6df800d139b32cdd35d61905067fd7e52ae21d91b069d94a99736ea57d25f9968ee6
7
+ data.tar.gz: 804d6d566f1e6c546f1f94a9235b43ba69fb451f298987855c40a281033144fd1ee44ea53e0fdf764f1d6f2bfe29e6902fd1bb065d75f6b4eba3212feaca367a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helmsnap (0.4.1)
4
+ helmsnap (0.4.2)
5
5
  colorize
6
6
 
7
7
  GEM
@@ -23,9 +23,8 @@ class Helmsnap::Check
23
23
  result = Helmsnap.run_cmd("which", "colordiff", allow_failure: true)
24
24
  util = result.success ? "colordiff" : "diff"
25
25
 
26
- diff = Helmsnap.run_cmd(
27
- util, "--unified", "--recursive", snapshots_path, temp_dir_path, allow_failure: true
28
- ).output
26
+ cmd_parts = [util, "--unified", "--recursive", snapshots_path, temp_dir_path]
27
+ diff = Helmsnap.run_cmd(*cmd_parts, allow_failure: true).output
29
28
 
30
29
  diff.strip.empty?
31
30
  ensure
@@ -9,6 +9,7 @@ class Helmsnap::Command
9
9
 
10
10
  def initialize(cmd, stdout: $stdout, stderr: $stderr, allow_failure: false)
11
11
  self.cmd = cmd
12
+ self.output = +""
12
13
  self.stdout = stdout
13
14
  self.stderr = stderr
14
15
  self.allow_failure = allow_failure
@@ -21,12 +22,10 @@ class Helmsnap::Command
21
22
 
22
23
  private
23
24
 
24
- attr_accessor :cmd, :stdout, :stderr, :allow_failure
25
+ attr_accessor :cmd, :output, :stdout, :stderr, :allow_failure
25
26
 
26
27
  def run_command
27
28
  Open3.popen3(cmd) do |_in, out, err, wait_thr|
28
- output = +""
29
-
30
29
  while (chunk = out.gets)
31
30
  Helmsnap::Console.print(stdout, chunk)
32
31
  output << chunk
@@ -34,15 +33,21 @@ class Helmsnap::Command
34
33
 
35
34
  exit_status = wait_thr.value
36
35
  success = exit_status.success?
37
-
38
- if !success && !allow_failure
39
- Helmsnap::Console.error(stderr, err.read)
40
- Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
41
- exit 1
42
- end
36
+ handle_error!(exit_status, err.read) unless success
43
37
 
44
38
  Helmsnap::Console.print(stdout, "\n")
45
39
  Result.new(success, output)
46
40
  end
47
41
  end
42
+
43
+ def handle_error!(exit_status, err_output)
44
+ Helmsnap::Console.error(stderr, err_output)
45
+
46
+ if allow_failure
47
+ output << err_output
48
+ else
49
+ Helmsnap::Console.error(stderr, "Command failed with status #{exit_status.to_i}")
50
+ exit 1
51
+ end
52
+ end
48
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helmsnap
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helmsnap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov