Last active
April 6, 2019 08:50
-
-
Save jamband/4554414 to your computer and use it in GitHub Desktop.
Yii + PHPUnit + watchr + terminal-notifier
This file contains 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
watch('./(.*).php') { |m| changed(m[0]) } | |
def changed(file) | |
run "clear && cd tests && phpunit unit" | |
end | |
def run(cmd) | |
result = `#{cmd}` | |
puts result | |
notify result | |
end | |
def notify(result) | |
message = result.split("\n").last(3) | |
title = message.find { |e| /FAILURES/ =~ e } ? "FAILURES" : "PASS" | |
if title == "FAILURES" | |
info = /\x1b\[37;41m\x1b\[2K(.*)/.match(message[1])[1] | |
else | |
if result.index("Call Stack:") | |
title = "ERROR" | |
info = "Please check the error message ..." | |
else | |
info = /\x1b\[30;42m\x1b\[2K(.*)/.match(message[1])[1] | |
end | |
end | |
require 'rubygems' | |
require 'terminal-notifier' | |
TerminalNotifier.notify(info, :title => title, :group => "phpunit") | |
end |
This file contains 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
sudo gem install watchr | |
sudo gem install terminal-notifier |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment