brushtechnology / fabricate

The better build tool. Finds dependencies automatically for any language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Watch to auto-build

GoogleCodeExporter opened this issue · comments

It would be great to have WAF automatically execute the steps required when 
files change.

This may allow something like SASS --watch which saves a lot of time.

The watch should allow to specify a target target so that only that is built 
automatically.

Original issue reported on code.google.com by wer...@beroux.com on 9 Sep 2013 at 11:51

[Watchdog](https://github.com/gorakhargosh/watchdog) seems to help a lot on 
that.

Here is a script which does that so it should be easy to incorporate it in 
fabricate:

    import sys
    import time
    from watchdog.observers import Observer
    from watchdog.tricks import ShellCommandTrick

    if __name__ == __main__:
        event_handler = ShellCommandTrick(shell_command='python build.py', wait_for_process=True)
        observer = Observer()
        observer.schedule(event_handler, '.', recursive=True)
        observer.start()
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            observer.stop()
        observer.join()

It has a possible issue, when you touch a file it'll be recorded as a CREATE 
followed right after by a MODIFY event. There should probably be a buffer of a 
few milliseconds. Possibly the files could be filtered to include only some of 
them but that's more optional for now.

Original comment by wer...@beroux.com on 10 Sep 2013 at 11:52

  • Added labels: ****
  • Removed labels: ****