nanoc-tidy.rb 0.5.5 → 0.6.1

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: 3c13d772e4ae2e2a1efc8ca32dec153769c19760bcbd6600ca1ec1501cf7e6df
4
- data.tar.gz: 2787f7c6199213d0d819e74a81b0f29e32e39a09afa57a09f092d939a5dcfba1
3
+ metadata.gz: ee29f7af6d3dbaf443aa2e35e52e696f184481641a493a29292d110760776c07
4
+ data.tar.gz: c42f3696900ea751574072d35a0005ed4dd2442cde77640e7a56a23f9794a500
5
5
  SHA512:
6
- metadata.gz: a8e30af2decf9ca18a7d5f0c585682bc7399c8c1809f9039b0ed33480d6db7e5aecb8ef7621c7e48b166cd596491e456cd5fe7f2f2089649680896d6ae7f58a8
7
- data.tar.gz: b2d1b2407f3187959dff0ef7d483a98c83fdd269691021aa6b2077d35033f9006c686eec58386d9505291238bb897f7f895bc355bbd863e30c865d2e3251c309
6
+ metadata.gz: bb1ad99a6c41a010f04d96483aac6cec646b153aeaaa0f827e2c2f176e5d0890435021a301e434600ab37623e5b824db75ce41826bde6b864a2da76a8e5be4ee
7
+ data.tar.gz: 648fa0abae522cf95225adc508991a7f5698cc4573e3d1cafd56a211fec6376a460c800142521bfe1ca4d400657b2b48fd96cf0074fdcaf2999a35d88259479f
@@ -26,7 +26,8 @@ module Nanoc::Tidy
26
26
  path = temporary_file(content).path
27
27
  spawn tidy,
28
28
  [*default_argv, *(options[:argv] || []), "-modify", path],
29
- log: File.join(tmpdir, "tidy-html5.log")
29
+ err: File.join(tmpdir, "stderr"),
30
+ out: File.join(tmpdir, "stdout")
30
31
  File.read(path).tap { rm(path) }
31
32
  end
32
33
 
@@ -1,9 +1,31 @@
1
1
  module Nanoc::Tidy
2
2
  module Spawn
3
+ require "securerandom"
4
+ require "fileutils"
3
5
  Error = Class.new(RuntimeError)
4
- def spawn(exe, argv, log:)
6
+
7
+ ##
8
+ # Spawns a process
9
+ #
10
+ # @param [String] exe
11
+ # The path to an executable
12
+ #
13
+ # @param [Array<String>] argv
14
+ # An array of command line arguments
15
+ #
16
+ # @param [String] err
17
+ # A path where stderr is redirected to
18
+ #
19
+ # @param [String] out
20
+ # A path where stdout is redirected to
21
+ #
22
+ # @return [void]
23
+ def spawn(exe, argv, err:, out:)
24
+ hex = SecureRandom.hex
25
+ err = "#{err}-ID#{hex}"
26
+ out = "#{out}-ID#{hex}"
5
27
  Kernel.spawn(
6
- exe, *argv, { STDOUT => log, STDERR => log }
28
+ exe, *argv, { STDERR => err, STDOUT => out }
7
29
  )
8
30
  Process.wait
9
31
  status = $?
@@ -14,16 +36,22 @@ module Nanoc::Tidy
14
36
  # * 2: has errors
15
37
  return if [0, 1].include?(status.exitstatus)
16
38
 
39
+ msgs = [err, out].map do
40
+ FileUtils.touch(_1)
41
+ [_1.gsub(Dir.getwd, ''), ":", File.binread(_1)].join
42
+ end.join("\n")
17
43
  raise Error,
18
44
  "#{File.basename(exe)} exited unsuccessfully " \
19
45
  "(" \
20
46
  "exit code: #{status.exitstatus}, " \
21
47
  "item: #{item.identifier}" \
22
48
  ")" \
23
- "\n" \
24
- "#{log.gsub(Dir.getwd, '')[1..]}:" \
25
- "#{File.binread(log)}" \
49
+ "\n#{msgs}",
26
50
  []
51
+ ensure
52
+ [err, out]
53
+ .select { File.exist?(_1) }
54
+ .each { FileUtils.rm(_1) }
27
55
  end
28
56
  end
29
57
  end
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.5.5"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-tidy.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'