Skip to content

Instantly share code, notes, and snippets.

@mwotton
Created April 26, 2011 23:47
Show Gist options
  • Save mwotton/943429 to your computer and use it in GitHub Desktop.
Save mwotton/943429 to your computer and use it in GitHub Desktop.
def guarded(task)
%x{#{task}}.tap { raise "bad exit" if $?.exitstatus!=0 }
rescue => e
yield e if block_given?
end
guarded("git config --global github.token") do |error|
abort "please add your token to ~/.gitconfig with git config --global github.token MYTOKEN"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment