Skip to content

Instantly share code, notes, and snippets.

@mirek
Last active December 27, 2015 11:29
Show Gist options
  • Save mirek/7318623 to your computer and use it in GitHub Desktop.
Save mirek/7318623 to your computer and use it in GitHub Desktop.
nodejs textmate 2 run command
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU
require "#{ENV["TM_SUPPORT_PATH"]}/lib/escape"
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/save_current_document"
require "#{ENV["TM_SUPPORT_PATH"]}/lib/tm/executor"
TextMate.save_if_untitled('cs')
TextMate::Executor.run(e_sh(ENV['TM_NODEJS'] || 'node'), ENV['TM_FILEPATH']) do |str, type|
if type == :err
if str =~ /
( ^ .* \b at \b .* \( )
( ([^)]+) : (\d+) : (\d+) )
( \) .* $ )
/x
prefix, innards, file, line, col, suffix = $1, $2, $3, $4, $5, $6
"<span class=\"err\">#{htmlize prefix}<a href=\"txmt://open?url=file://#{e_url file}&line=#{line}&column=#{col}\">#{htmlize innards}</a>#{htmlize suffix}</span><br>\n"
end
end
end
@mirek
Copy link
Author

mirek commented Nov 5, 2013

Name: Run nodejs
Scope Selector: source.js
Key Equivalent: CMD+R
Save: Modified Documents
Input: Document -> Format: Text
Output: Show in New Window -> Format: HTML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment