jekyll_pre 1.4.2 → 1.4.4

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: 9891991d8f4517372a76f9a52f60dd8d063a5527738b2bd5194fc749bba5a02e
4
- data.tar.gz: 52b238c5f9aee99c593bd552552411503a0dd49f2c470b1c48bc6600c257e114
3
+ metadata.gz: e7d377e36ea0a56b8f739226880016398a4f777fb510c43bee01bd3010c7ddd3
4
+ data.tar.gz: 9a3330b73d8f8c314ce9c363fe9f0acf1a3092de37c3a156b4ba0bc65a2e8d43
5
5
  SHA512:
6
- metadata.gz: 3629fe65cd677c4d964b89e5197f6f18862177da853d862a905bd0162eb6265aa3922e196a34c0149bfd627e9d959155a39675b5ebccde9dfc5cd5f6fa05a355
7
- data.tar.gz: 341e7a4863fc7dccb227d997154cccf677ef4576403f8c75b74cc1a596cbc1c1232d95df1257d052c03f6a65d0fb2104024398902b1fa98e68f54b912df46974
6
+ metadata.gz: cd099f9d1b63bfd5be501d998a7ed594cb9597a433d644dce96554b642079c94e944e28ebc99260bdf08ee0ee649593843063a14c9559b8a19f290242ffe6d95
7
+ data.tar.gz: 8b5e35e564f47477a96a7bab9b69aee4477e3ab11e0977d062357df2691c5c6b03054a75d4f524387e364a2d0e5c7f1653db7b0b9653f71cbb76e1e23474eddb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.4
4
+
5
+ * Fixed the empty response problem introduced by v1.4.3.
6
+
7
+
8
+ ## 1.4.3
9
+
10
+ * Added the `no_stderr` option, which discards any STDERR output.
11
+
12
+
3
13
  ## 1.4.2
4
14
 
5
15
  * Added missing `require` in `pre_tag_block.rb`.
data/README.md CHANGED
@@ -61,6 +61,16 @@ This Jekyll plugin provides 3 new Liquid tags that work together:
61
61
  - `die_if_error` – Set `false` to treat exceptions generated by this plugin as non-fatal.
62
62
  Instead of terminating Jekyll with an error message, the message will be displayed as an error by the Jekyll logger.
63
63
  - `no_escape` – Do not HTML escape the result of running the shell command.
64
+ - `no_stderr` - Discard STDERR output.
65
+ This is helpful for suppressing annoying `groff` error messages that are emitted when the `exec` subcommand runs `man`.
66
+ Use it like this:
67
+
68
+ ```html
69
+ {% pre copyButton dedent shell %}
70
+ {% noselect %}{% exec no_stderr man netplan %}
71
+ {% endpre %}
72
+ ```
73
+
64
74
  - `no_strip` – Do not remove leading and trailing whitespace from the result.
65
75
  - `wrapper_class` class applied to outer `div`.
66
76
  - `wrapper_style` style applied to outer `div`.
data/jekyll_pre.gemspec CHANGED
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.version = JekyllPreVersion::VERSION
34
34
 
35
35
  spec.add_dependency 'jekyll', '>= 3.5.0'
36
- spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
36
+ spec.add_dependency 'jekyll_plugin_support', '>= 0.8.0'
37
37
  spec.add_dependency 'rack'
38
38
  end
data/lib/exec_tag.rb CHANGED
@@ -77,31 +77,43 @@ module JekyllPreModule
77
77
 
78
78
  @no_escape = @helper.parameter_specified? 'no_escape'
79
79
  @no_strip = @helper.parameter_specified? 'no_strip'
80
+ @no_stderr = @helper.parameter_specified? 'no_stderr'
80
81
  @die_if_nonzero = @helper.parameter_specified?('die_if_nonzero') # Implies die_if_error
81
82
  @die_if_error = @helper.parameter_specified?('die_if_error') | @die_if_nonzero
82
83
  end
83
84
 
84
85
  # References @cd
85
86
  # Defines @child_status
87
+ # Ignores stderr output
86
88
  # @return result of running command
87
89
  # @param command [String] Shell command to execute
88
90
  def run_command(command)
89
- result = if @cd
90
- Dir.chdir(@cd) do
91
- `#{command}`
92
- end
93
- else
94
- `#{command}`
95
- end
96
- @child_status = $CHILD_STATUS
97
- result
91
+ stdout_str = ''
92
+ stderr_str = ''
93
+ if @cd
94
+ Dir.chdir(@cd) do
95
+ @logger.debug { "Executing '#{command}' from '#{@cd}'" }
96
+ stdout_str, stderr_str, @child_status = Open3.capture3 command
97
+ end
98
+ else
99
+ @logger.debug { "Executing '#{command}'" }
100
+ stdout_str, stderr_str, @child_status = Open3.capture3 command
101
+ end
102
+ unless @no_stderr
103
+ stderr_str.strip!
104
+ unless stderr_str.empty?
105
+ @logger.info do
106
+ "'#{command}' STDERR=#{stderr_str}\nThe exec subcommand's 'no_stderr' option suppresses this message."
107
+ end
108
+ end
109
+ end
110
+ stdout_str
98
111
  rescue StandardError => e
99
112
  msg = self.class.remove_html_tags(e.message) +
100
113
  " from executing '#{@original_command}' on line #{@line_number} (after front matter) of #{@page['path']}"
101
114
  raise PreError, msg.red, [] if @die_if_error
102
115
  ensure
103
- @child_status = $CHILD_STATUS
104
- result
116
+ stdout_str
105
117
  end
106
118
 
107
119
  JekyllPluginHelper.register(self, 'exec')
@@ -1,3 +1,3 @@
1
1
  module JekyllPreVersion
2
- VERSION = '1.4.2'.freeze
2
+ VERSION = '1.4.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_pre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-29 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.0
33
+ version: 0.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.0
40
+ version: 0.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rack
43
43
  requirement: !ruby/object:Gem::Requirement