{"id":16389611,"url":"https://github.com/yuce/erwatch","last_synced_at":"2026-06-15T06:33:01.768Z","repository":{"id":143648372,"uuid":"52408886","full_name":"yuce/erwatch","owner":"yuce","description":"Watch files and directories for changes.","archived":false,"fork":false,"pushed_at":"2016-05-30T03:36:24.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-05-08T03:13:38.664Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-24T02:44:10.000Z","updated_at":"2019-09-08T20:53:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d587b9e-95e0-470a-a503-04e5c5aff83d","html_url":"https://github.com/yuce/erwatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yuce/erwatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Ferwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Ferwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Ferwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Ferwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuce","download_url":"https://codeload.github.com/yuce/erwatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Ferwatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34351448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:33:46.425Z","updated_at":"2026-06-15T06:33:01.750Z","avatar_url":"https://github.com/yuce.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Erwatch\n\n**Erwatch** is an Erlang/OTP application for tracking changes in\na file system. It can be used with Erlang/OTP (17+ *should* be OK) and\noptionally [rebar3](http://www.rebar3.org/).\nIt is only tested on Linux/OSX, but only Erlang/OTP standard library functions\nare used, so it should work on any platform where Erlang/OTP runs.\n\n## News\n\n* **2016-03-08**: Major change in **Erwatch** API.\n    * Removed `erwatch:add_wildcard/2` function. You have to specify the wildcards to `erwatch:new/1` or `erwatch:new/2` instead.\n    * The initial changesets are not returned. Use `filelib:wildcard/1` or `filelib:wildcard/2` instead.\n\n## Install\n\n**Erwatch** uses [rebar3](http://www.rebar3.org/) to build and tests and\nit is available on [hex.pm](https://hex.pm/). Just include the following\nin your `rebar.config`:\n\n```erlang\n{deps, [erwatch]}.\n```\n\n## Build\n\n    $ rebar3 compile\n\n## Usage\n\n\u003e Warning!\n\u003e Erwatch (*currently*) uses polling to determine file system changes.\n\u003e Setting the poll interval too frequent (lower) is not recommended\n\u003e for wildcards which may return a large number of paths.\n\nSince **Erwatch** is an OTP application, it must be started before\nusing. You can do that by including `erwatch` in your `*.app.src` or `*.app` file, like:\n\n```erlang\n...\n  {applications,\n   [kernel,\n    stdlib,\n    erwatch\n   ]},\n...\n```\n\nOr, start it manually:\n\n```erlang\nok = application:start(erwatch).\n```\n\n**rebar3** has a nice way of starting apps in the shell, you can try:\n\n    $ rebar3 shell --apps rewatch\n\n\n**Erwatch** supports both the synchronous/on demand and asynchronous/message based way\nof tracking changes.\n\nUse `erwatch:new/1` to create a watch with default options, or `erwatch:new/2`\nto create a watch with specified options. The list of wildcards is mandatory for both:\n\n```erlang\n% on demand watch:\n{ok, Watch} = erwatch:new([\"/tmp/somedir/**/src/*.erl\"]),\n% a watch that fires every 3000 milliseconds, and sends a message on changes\n{ok, AnotherWatch} = erwatch:new([\"/tmp/somedir/**/src/*.erl\"],\n                                 [{interval, 3000}]).\n```\n\nSee [filelib:wildcard/1](http://erlang.org/doc/man/filelib.html#wildcard-1)\ndocumentation for available wildcard patterns. Note that, the given wildcard is\nrelative to the current working directory.\n\nWhether you use *synchronous* or *asynchronous* watches, the change sets are\nin the form of list of `{Action, Path}` pairs, where `Action` is one of\n`added`, `updated` or `deleted`.\n\nYou can change the poll interval and switch between synchronous\nand asynchronous modes using `erwatch:set_interval/2`. An interval of\n`0` will make the watch synchronous and `\u003e 0` will make it asynchronous.\n\n```erlang\nerwatch:set_interval(1000, Watch).\n```\n\nIt is possible to pause an asynchronous watch using `erwatch:pause/1` and\nresume it using `erwatch:resume/1`.\n\n```erlang\nerwatch:pause(Watch),\n% later...\nerwatch:resume(Watch).\n```\nWhen the time comes, you can kill a watch with `erwatch:remove/1`:\n\n```erlang\nerwatch:remove(Watch).\n```\n\n### Synchronous / On Demand Usage\n\nCreate a watch:\n\n```erlang\n{ok, Watch} = erwatch:new([\"/tmp/foo1/*\", \"/tmp/bar2\"]).\n```\n\nAssuming `/tmp/foo1` is a directory and `/tmp/bar2` is a file,\ncreate, modify, delete directories, files in `/tmp/foo1` and/or\ncreate, modify, delete `/tmp/bar2`.\n\nRetrieve changes:\n\n```erlang\nerwatch:get_changes(Watch).\n```\n\nReturns e.g.:\n\n```erlang\n[{added,\"/tmp/foo1/myfile\"},\n {updated,\"/tmp/foo1/yourfile\"},\n {updated,\"/tmp/foo1/x\"},\n {deleted,\"/tmp/bar2\"}]\n```\n\n### Asynchronous / Message Based Usage\n\nIn this mode, **Erwatch** will send `erwatch@changes` messages to the\nparent process (*currently the process which created the watch*) on\nfile system changes.\n\nCreate a watch with an interval:\n\n```erlang\n{ok, Watch} = erwatch:new([\"/tmp/foo1/*\", \"/tmp/bar2\"],\n                          [{interval, 1000}]).\n```\n\nAssuming `/tmp/foo1` is a directory and `/tmp/bar2` is a file,\ncreate, modify, delete directories, files in `/tmp/foo1` and/or\ncreate, modify, delete `/tmp/bar2`.\n\nReceive changes:\n\n```erlang\nloop() -\u003e\n    receive\n        {erwatch@changes, Watch, ChangeSet} -\u003e\n            % do something with `ChangeSet`\n            loop()\n        _ -\u003e\n            % received some other message...\n            loop()\n    end.\n```\nThe `ChangeSet` value might be:\n\n```erlang\n[{added,\"/tmp/foo1/myfile\"},\n {updated,\"/tmp/foo1/yourfile\"},\n {updated,\"/tmp/foo1/x\"},\n {deleted,\"/tmp/bar2\"}]\n```\n\n## Examples\n\nSee [examples/watch.escript](https://github.com/yuce/erwatch/blob/master/examples/watch.escript)\nfor a simple file watcher.\n\n## License\n\n```\nCopyright (c) 2016, Yuce Tekol \u003cyucetekol@gmail.com\u003e.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions of source code must retain the above copyright\n  notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright\n  notice, this list of conditions and the following disclaimer in the\n  documentation and/or other materials provided with the distribution.\n\n* The names of its contributors may not be used to endorse or promote\n  products derived from this software without specific prior written\n  permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuce%2Ferwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuce%2Ferwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuce%2Ferwatch/lists"}