Created
January 25, 2012 01:55
-
-
Save dux/1674131 to your computer and use it in GitHub Desktop.
Sass / Less / Coffee compiler - Ruby command line
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
#!/usr/bin/env ruby | |
# sudo gem install sass | |
# npm install less -g | |
# npm install coffee -g | |
p 'Dux sass/less/coffee compiler v0.1' | |
while true | |
sleep 1 if (@last_mtime ||=0) > 0 | |
file = `find -type f | grep -i -e ".scss" -e ".coffee" -e ".less" | xargs ls -alt`.split("\n").first.split(/\s+/).last | |
file_mtime = File.mtime(file).to_i | |
next if @last_mtime == file_mtime | |
@last_mtime = file_mtime | |
elms = file.split('.') | |
ext = elms.pop | |
file_base = elms.join('.') | |
case ext | |
when /scssc/ | |
next | |
when 'coffee' | |
`coffee -c #{file}` | |
when 'less' | |
`/usr/local/lib/node_modules/less/bin/lessc #{file} #{file_base}.css` | |
when 'scss' | |
`sass #{file} > #{file_base}.css` | |
else | |
p "Unsupported - #{ext}" | |
end | |
p "OK: #{file}" if $? == 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment