Created
September 28, 2012 07:27
-
-
Save gregwork/3798457 to your computer and use it in GitHub Desktop.
auto puppet-lint/syntax check via guard-shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Uses guard and guard-shell for auto lint/syntax check on saving | |
# | |
# 'gem install guard guard-shell puppet' will get you the dependencies. | |
# Drop this in 'Guardfile' in the root of your puppet dev directory. | |
# | |
# Run 'guard' to get started. | |
# Disable Pry interactor; this blocks the filesystem change listenener | |
# https://github.com/guard/guard/issues/357 | |
interactor :off | |
notification :tmux | |
ignore %r{.*\.swp$}, %r{^.*~$} | |
guard 'shell' do | |
watch(/.*\.pp/) do |m| | |
exitstatus = :success | |
system("echo #{m}") | |
system("echo '\nLint:'") | |
if ! system("puppet-lint '#{m}'") | |
exitstatus = :pending | |
end | |
system("echo '\nSyntax:'") | |
if ! system("puppet parser --verbose validate '#{m}'") | |
exitstatus = :failed | |
end | |
n nil, nil, exitstatus | |
end | |
watch(/.*\.erb$/) do |m| | |
exitstatus = :success | |
system("echo #{m}") | |
if ! system("erb -x -T - #{m} | ruby -c") | |
exitstatus = :failed | |
end | |
n nil, nil, exitstatus | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment