Skip to content

Commit d71c464

Browse files
authored
Merge pull request chriskuehl#8 from alexjurkiewicz/remove-shell-scripts
Remove the need for shell script shims
2 parents 06b5bf4 + 6b2e6c8 commit d71c464

File tree

7 files changed

+41
-58
lines changed

7 files changed

+41
-58
lines changed

__fake_gem.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ Gem::Specification.new do |s|
77

88
s.bindir = 'ruby-stubs'
99
s.executables = ['puppet-validate', 'erb-validate', 'epp-validate']
10-
s.files = Dir['bin/*']
1110
end

bin/epp-validate

Lines changed: 0 additions & 13 deletions
This file was deleted.

bin/erb-validate

Lines changed: 0 additions & 13 deletions
This file was deleted.

bin/puppet-validate

Lines changed: 0 additions & 22 deletions
This file was deleted.

ruby-stubs/epp-validate

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
# we can't deal with ruby, so we exec a shell script instead
2-
script = File.expand_path('../../bin/epp-validate', File.absolute_path(__FILE__))
3-
exec([script, script], *ARGV)
1+
require 'English'
2+
3+
status = 0
4+
ARGV.each do |file|
5+
output = `puppet epp validate "#{file}" 2>&1`
6+
next if $CHILD_STATUS.exitstatus == 0
7+
puts "#{file}: failed epp validation"
8+
puts output
9+
status = 1
10+
end
11+
12+
exit status
413

514
# vim: ft=ruby

ruby-stubs/erb-validate

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
# we can't deal with ruby, so we exec a shell script instead
2-
script = File.expand_path('../../bin/erb-validate', File.absolute_path(__FILE__))
3-
exec([script, script], *ARGV)
1+
require 'English'
2+
3+
status = 0
4+
ARGV.each do |file|
5+
output = `erb -x -P -T - -- "#{file}" | ruby -c 2>&1`
6+
next if $CHILD_STATUS.exitstatus == 0
7+
puts "#{file}: failed erb validation"
8+
puts output
9+
status = 1
10+
end
11+
12+
exit status
413

514
# vim: ft=ruby

ruby-stubs/puppet-validate

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
# we can't deal with ruby, so we exec a shell script instead
2-
script = File.expand_path('../../bin/puppet-validate', File.absolute_path(__FILE__))
3-
exec([script, script], *ARGV)
1+
require 'English'
2+
3+
status = 0
4+
options = []
5+
ARGV.each do |arg|
6+
if arg =~ /^--.+=.+$/
7+
options.append arg
8+
next
9+
end
10+
output = `puppet parser validate #{options.join(' ')} -- "#{arg}" 2>&1`
11+
next if $CHILD_STATUS.exitstatus == 0
12+
puts "#{arg}: failed Puppet validation"
13+
puts output
14+
status = 1
15+
end
16+
17+
exit status
418

519
# vim: ft=ruby

0 commit comments

Comments
 (0)