Skip to content

Commit

Permalink
Merge pull request #69 from alexiri/fix_erb
Browse files Browse the repository at this point in the history
Only try to validate .erb or .epp files
  • Loading branch information
domcleal authored Jan 25, 2017
2 parents ae545ec + 9894422 commit 0ecd0e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-syntax/tasks/puppet-syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def filelist_manifests
end

def filelist_templates
filelist("**/templates/**/*")
filelist(["**/templates/**/*.erb", "**/templates/**/*.epp"])
end

def filelist_hiera_yaml
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet-syntax/templates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def check(filelist)
filelist.each do |file|
if File.extname(file) == '.epp' or PuppetSyntax.epp_only
errors.concat validate_epp(file)
else
elsif File.extname(file) == '.erb'
errors.concat validate_erb(file)
end
end
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/test_module/templates/ignore.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is plain text
<% This is not valid Ruby %>
This is also plain text
7 changes: 7 additions & 0 deletions spec/puppet-syntax/templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
expect(res).to match([])
end

it 'should ignore files without .erb extension' do
files = fixture_templates('ignore.tpl')
res = subject.check(files)

expect(res).to match([])
end

if Puppet::PUPPETVERSION.to_f < 3.7
context 'on Puppet < 3.7' do
it 'should throw an exception when parsing EPP files' do
Expand Down

0 comments on commit 0ecd0e0

Please sign in to comment.