nanoc-tidy.rb 0.5.5 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c13d772e4ae2e2a1efc8ca32dec153769c19760bcbd6600ca1ec1501cf7e6df
4
- data.tar.gz: 2787f7c6199213d0d819e74a81b0f29e32e39a09afa57a09f092d939a5dcfba1
3
+ metadata.gz: f2a117a2fa83b551326ed6ba05761c1744f182144b2980cd8246757853c67ecc
4
+ data.tar.gz: 362656c6f68fe0791665ecffaa9606cebeb2950eabe08db6f98f3fe8c1f32d84
5
5
  SHA512:
6
- metadata.gz: a8e30af2decf9ca18a7d5f0c585682bc7399c8c1809f9039b0ed33480d6db7e5aecb8ef7621c7e48b166cd596491e456cd5fe7f2f2089649680896d6ae7f58a8
7
- data.tar.gz: b2d1b2407f3187959dff0ef7d483a98c83fdd269691021aa6b2077d35033f9006c686eec58386d9505291238bb897f7f895bc355bbd863e30c865d2e3251c309
6
+ metadata.gz: 8c19227fa2c5b0386bfeb148b6ecbc664d42847dc1267370228e68139318749ad53c3ec0b6429f175eb77c04540caa388510ecb4920c50e6846c82c40921389d
7
+ data.tar.gz: aa0327d39187dee54a4cc3dd356345b2ebaafd4167e46a83698b275c2e0eaffb4cb6d406dba49ec07490a89f6bc7c6b7c76a63a3609b7762a5f351f76f8bcdb3
@@ -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,15 +36,19 @@ 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
+ ensure
43
+ FileUtils.rm(_1)
44
+ end.join("\n")
17
45
  raise Error,
18
46
  "#{File.basename(exe)} exited unsuccessfully " \
19
47
  "(" \
20
48
  "exit code: #{status.exitstatus}, " \
21
49
  "item: #{item.identifier}" \
22
50
  ")" \
23
- "\n" \
24
- "#{log.gsub(Dir.getwd, '')[1..]}:" \
25
- "#{File.binread(log)}" \
51
+ "\n#{msgs}",
26
52
  []
27
53
  end
28
54
  end
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.5.5"
3
+ VERSION = "0.6.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'