Skip to content

Auto-rebuild on file change #113

Closed
Closed
@snoyberg

Description

@snoyberg
Contributor

Moving from an internal issue tracker:

Just an idea I had: what about having a command (maybe autobuild) that scans a directory for any changes to files (via fsnotify) and, on a change, automatically rebuilds? I know this is something that I would use regularly.

Not high priority, just an idea.

Activity

added this to the Later improvements milestone on May 29, 2015
chrisdone

chrisdone commented on May 29, 2015

@chrisdone
Member

Yeah, it would be neat if Shake coud do this as it already knows what files to be tracking. @ndmitchell But I guess with a simple notification of "one file in this directory and subdirs changed" we can call build and it's fine.

There's definitely general demand for this; there are like 5 proper projects for recompiling like this out there.

ndmitchell

ndmitchell commented on May 29, 2015

@ndmitchell
Contributor

Via shakeLiveFiles you can get notified of which files Shake is interested in. There's no direct support for what you describe, but it is planned/vaguely thought about. Now I use file tracker in ghcid, it's much more likely.

snoyberg

snoyberg commented on May 29, 2015

@snoyberg
ContributorAuthor

If we want to do this properly, we'd have to go quite a bit deeper, like looking at all of the .hi files to track the addDependentFiles in them (something I'm dealing with right now on the yesod devel front).

snoyberg

snoyberg commented on May 29, 2015

@snoyberg
ContributorAuthor
ndmitchell

ndmitchell commented on May 29, 2015

@ndmitchell
Contributor

I would have thought a far simpler "anything under this directory changes, i rerun build" would be sufficient - as long as you get build fast enough. Generally people only put dependent files in the same folder as the project.

snoyberg

snoyberg commented on May 29, 2015

@snoyberg
ContributorAuthor

That could work. We'd probably get hit with some annoying corner cases, such as .git and dist, where there are lots of files and adding watchers for all of them could actually slow us down significantly. Special casing those may solve that problem though.

chrisdone

chrisdone commented on May 29, 2015

@chrisdone
Member

I suppose if your project generates a lot of files, watching the whole dir could come with a performance penalty? In any case watching the whole dir vs just the shakeLiveFiles vs more detail could be considered levels of implementation of the feature.

modified the milestone: 0.2.0.0 on Jun 30, 2015
self-assigned this
on Jun 30, 2015
snoyberg

snoyberg commented on Jun 30, 2015

@snoyberg
ContributorAuthor

Working on this now, I want it too much to wait :)

added a commit that references this issue on Jun 30, 2015
snoyberg

snoyberg commented on Jun 30, 2015

@snoyberg
ContributorAuthor

Closing, this is implemented. If there are bugs, we can follow up in separate issues.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @chrisdone@snoyberg@ndmitchell

      Issue actions

        Auto-rebuild on file change · Issue #113 · commercialhaskell/stack