Created
October 16, 2011 13:32
-
-
Save tricknotes/1290877 to your computer and use it in GitHub Desktop.
Hamlをコンパイルするwatchr
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
require "open3" | |
watch('(.*)\.haml') do |md| | |
stdin, stdout, stderr = Open3.popen3("haml #{md[0]}") | |
error_message = '' | |
unless stderr.eof? | |
error_message << stderr.to_a.join | |
end | |
unless error_message.empty? | |
system "growlnotify", "-t", md[0], "-m", error_message | |
next | |
end | |
File.open("./dist/#{md[1]}.html", 'w') do |html| | |
html << stdout.to_a.join | |
end | |
system "growlnotify", "-t", md[0], "-m", "Compiled successfully." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment