[TxMt] Ruby require_cmd equivalent.

Simon Gregory simon at helvector.org
Thu Nov 1 22:28:50 UTC 2007


> [...] Should probably be parameterized so we can later move it to a  
> support library. Should maybe also check that the found file is  
> executable.

I've altered it to the following which appears to work fine for me.

require SUPPORT + '/lib/exit_codes'

def require_cmd(cmd)
     exists = ENV['PATH'].split(':').any? { |dir|
         File.executable? File.join(dir, cmd)
     }
     unless exists
         puts '<h3 class="error">Couldn\'t find ‘' + cmd + '’</ 
h3><p>Locations searched:</p><p><pre>'
         puts ENV['PATH'].gsub(/:/, "\n") + '</pre></p>'
         TextMate.exit_show_html()
     end
end

require_cmd "ant"

> And would be nice if it also supported TM_ANT.

Agreed, I need to update the bundle to support TM_ANT. I'll add it to  
my TODO list.

Thank you,
Simon





More information about the textmate mailing list