views:

158

answers:

2

I love TextMate as my editor for all things web, and so I'd like to use a snippet to use it with style.less files to automatically take advantage of the .less way of compiling .css files on the fly using the native

$ lessc {filepath} --watch

as suggested in the less documentation (link)

My (thanks to someone who wrote the LESS TM Bundle!) current TextMate snippet works well for writing the currently opened .less file to the .css file but I'd like to take advantage of the --watch parameter so that every change to the .less file gets automatically compiled into the .css file.

This works well when using the Terminal command line for it, so I am sure it must be possible to use it in an adapted version of the current LESS Command for TextMate since that only invokes the command to compile the file.

So how do I add the --watch flag to this command:?

#!/usr/bin/env ruby
file = STDIN.read[/lessc: ([^*]+\.less)/, 1] || ENV["TM_FILEPATH"]
system("lessc \"#{file}\"")

I assume it should be something like:

#!/usr/bin/env ruby
file = STDIN.read[/lessc: ([^*]+\.less)/, 1] || ENV["TM_FILEPATH"]
system("lessc \"#{file}\" --watch")

But doing so only crashes the TextMate.app.

Any ideas would be much appreciated.

Thanks for reading.

Jannis

A: 

Did you try running it as a background task?

system("lessc \"#{file}\" --watch &")

cloudhead
Jannis
why not just try something like this: http://b5.s3.quickshareit.com/bundleeditor361e2.png ?It makes more sense to run the compiler on save, which is what --watch checks for anyway.
cloudhead
A: 

I'm guessing you have to put the --watch parameter before the file parameter to lessc, like so:

system("lessc --watch \"#{file}\"")
mipadi