{"id":13724875,"url":"https://github.com/lukeed/watchlist","last_synced_at":"2025-10-09T18:24:07.653Z","repository":{"id":41156183,"uuid":"279508673","full_name":"lukeed/watchlist","owner":"lukeed","description":"Recursively watch a list of directories \u0026 run a command on any file system changes","archived":false,"fork":false,"pushed_at":"2022-10-26T21:02:40.000Z","size":69,"stargazers_count":263,"open_issues_count":5,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T18:51:26.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"lukeed"}},"created_at":"2020-07-14T07:02:54.000Z","updated_at":"2024-12-09T01:15:53.000Z","dependencies_parsed_at":"2022-08-10T01:42:51.404Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/watchlist","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwatchlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwatchlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwatchlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwatchlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/watchlist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252745150,"owners_count":21797747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-08-03T01:02:05.387Z","updated_at":"2025-10-09T18:24:02.603Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":["https://github.com/sponsors/lukeed"],"categories":["others","JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"logo.jpg\" alt=\"watchlist\" width=\"400\" /\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/watchlist\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/watchlist\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/lukeed/watchlist/actions\"\u003e\n    \u003cimg src=\"https://github.com/lukeed/watchlist/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/watchlist\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/dm/watchlist\" alt=\"downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=watchlist\"\u003e\n    \u003cimg src=\"https://packagephobia.now.sh/badge?p=watchlist\" alt=\"install size\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  Recursively \u003cb\u003ewatch\u003c/b\u003e a \u003cb\u003elist\u003c/b\u003e of directories \u0026 run a command on any file system changes\n\u003c/div\u003e\n\n\n## Features\n\n* Extremely lightweight\n* Simple [`fs.watch`](https://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener) wrapper\u003csup\u003e†\u003c/sup\u003e\n* Runs on macOS, Linux, and Windows\n* Recursively monitors all subdirectories\n* Optional ignore patterns\n\n\u003e \u003csup\u003e†\u003c/sup\u003e While `fs.watch` has its inconsistencies, efforts are made to normalize behavior across platforms.\n\n\n## Install\n\n```\n$ npm install --save-dev watchlist\n```\n\n\n## Usage\n\n***CLI***\n\n```sh\n# Run `npm test` on changes within \"src\" and \"test\" contents change\n$ watchlist src test -- npm test\n\n# Run `npm test` on changes within \"packages\", ignoring /fixtures/i\n$ watchlist packages --ignore fixtures -- npm test\n\n# Run `lint` script on ANY change\n$ watchlist -- npm run lint\n```\n\n***API***\n\n```js\nimport { watch } from 'watchlist';\n\nasync function task() {\n  console.log('~\u003e something updated!');\n  await execute_example(); // linter, tests, build, etc\n}\n\n// Run `task()` when \"{src,test}/**/*\" changes\n// Must also ignore changes to any `/fixture/i` match\nawait watch(['src', 'test'], task, {\n  ignore: 'fixtures'\n});\n```\n\n\n## CLI\n\nThe `watchlist` binary expects the following usage:\n\n```sh\n$ watchlist [...directory] [options] -- \u003ccommand\u003e\n```\n\n\u003e **Important:** The `--` is required! It separates your `command` from your `watchlist` arguments.\n\nPlease run `watchlist --help` for additional information.\n\n\n## API\n\n### watch(dirs: string[], handler: Function, options?: Options)\nReturns: `Promise\u003cvoid\u003e`\n\nWatch a list of directories recursively, calling `handler` whenever their contents are modified.\n\n#### dirs\nType: `Array\u003cString\u003e`\n\nThe list of directories to watch.\n\nMay be relative or absolute paths. \u003cbr\u003eAll paths are resolved from the `opts.cwd` location.\n\n#### handler\nType: `Function`\n\nThe callback function to run.\n\n\u003e **Note:** This may be a Promise/`async` function. Return values are ignored.\n\n#### options.cwd\nType: `String`\u003cbr\u003e\nDefault: `.`\n\nThe current working directory. All paths are resolved from this location. \u003cbr\u003eDefaults to `process.cwd()`.\n\n#### options.ignore\nType: `String` or `RegExp` or `Array\u003cString | RegExp\u003e`\n\nA list of patterns that should **not** be watched nor should trigger a `handler` execution. \u003cbr\u003eIgnore patterns are applied to file and directory paths alike.\n\n\u003e **Note:** Any `String` values will be converted into a `RegExp` automatically.\n\n#### options.clear\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nWhether or not the `console` should be cleared before re-running your `handler` function.\n\n\u003e **Note:** Defaults to `true` for the CLI! Pass `--no-clear` to disable.\n\n#### options.eager\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nWhen enabled, runs the `command` one time, after `watchlist` has initialized. When disabled, a change within the `dirs` list must be observed before the first `command` execution.\n\n\n### run(command: string, ...args)\nReturns: `Promise\u003cvoid\u003e`\n\nAll arguments to `watchlist.run` are passed to [`child_process.exec`][child_exec] directly.\n\n\u003e **Note:** Any `stdout` or `stderr` content will be piped/forwarded to your console.\n\n#### command\nType: `String`\n\nThe command string to execute. \u003cbr\u003eView [`child_process.exec`][child_exec] for more information.\n\n#### args\nType: `String`\n\nAdditional [`child_process.exec`][child_exec] arguments.\n\n\u003e **Important:** The `callback` argument is not available!\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n\n[child_exec]: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwatchlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fwatchlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwatchlist/lists"}