Skip to content

Instantly share code, notes, and snippets.

@barbuza
Created February 2, 2012 15:19
Show Gist options
  • Save barbuza/1723950 to your computer and use it in GitHub Desktop.
Save barbuza/1723950 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
file = STDIN.read[/lessc: ([^*]+\.less)/, 1] || ENV["TM_FILEPATH"]
outname = File.dirname(file) + "/" + File.basename(file, File.extname(file)) + ".css"
output = IO.popen("lessc \"#{file}\" 2>&1", "w+") do |pipe|
pipe.close_write
pipe.read
end
if $? != 0
puts output.gsub(/\[\d\d?m/, '')
else
puts "success"
File.open(outname, "w") { |f| f.write output }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment