Skip to content

Instantly share code, notes, and snippets.

@gregwork
Created September 28, 2012 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregwork/3798457 to your computer and use it in GitHub Desktop.
Save gregwork/3798457 to your computer and use it in GitHub Desktop.
auto puppet-lint/syntax check via guard-shell
# 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