code

Code: Prototype Auto-build TextMate Command

Bind to ⌘S. Will execute rake dist automatically if you just saved a file in the src directory.

#!/usr/bin/env ruby

# Save: Current File
# Input: None
# Output: Discard
# Scope: source.js.prototype

FILE = ENV['TM_FILEPATH']
DIR  = File.dirname(FILE)
if (DIR =~ /\/src$/)
  basedir = DIR.gsub(/\/src$/, '')
  Dir.chdir(basedir)
  `/usr/local/bin/rake dist -f #{basedir}/Rakefile`
end