Created
February 3, 2011 01:41
-
-
Save thurloat/808886 to your computer and use it in GitHub Desktop.
Aptana Javascript Ruble formatter. Replaces the JS Beautifier with Google's fixjsstyle script.
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
require 'ruble' | |
command "Reformat Document" do |cmd| | |
cmd.key_binding = "CTRL+ALT+COMMAND+F" | |
cmd.output = :replace_selection | |
cmd.input = :selection, :document | |
cmd.scope = "source.js" | |
cmd.invoke do | |
require 'open3' | |
require 'beautify2' | |
file_contents = Beautifier.new.js_beautify($stdin.read) | |
File.open('/tmp/test.js', 'w') do |f2| | |
f2.puts file_contents | |
end | |
sin, sout, serr = Open3.popen3('/usr/local/bin/fixjsstyle /tmp/test.js') | |
# Can outputting to the console. It's sorta annoying. | |
# STDERR.puts sout.readlines | |
File.open('/tmp/test.js', "r") do |fr| | |
puts fr.read | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
I've installed jsfixstyle on my Mac, but how do I tell Aptana to use it?