{"id":14982058,"url":"https://github.com/gulpjs/glob-watcher","last_synced_at":"2025-04-12T14:55:58.776Z","repository":{"id":12676398,"uuid":"15348451","full_name":"gulpjs/glob-watcher","owner":"gulpjs","description":"Watch globs and execute a function upon change, with intelligent defaults for debouncing and queueing.","archived":false,"fork":false,"pushed_at":"2023-05-31T00:14:04.000Z","size":47,"stargazers_count":80,"open_issues_count":4,"forks_count":59,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-29T15:14:42.144Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"IBM-Blue-Box-Help/help-documentation","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2013-12-20T21:20:48.000Z","updated_at":"2024-08-06T04:16:42.000Z","dependencies_parsed_at":"2023-01-13T17:04:47.855Z","dependency_job_id":null,"html_url":"https://github.com/gulpjs/glob-watcher","commit_stats":{"total_commits":71,"total_committers":11,"mean_commits":6.454545454545454,"dds":0.5211267605633803,"last_synced_commit":"b593a04512ecd7726050072d9193774d20455be9"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fglob-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fglob-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fglob-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fglob-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/glob-watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107827,"owners_count":20884797,"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-09-24T14:04:43.014Z","updated_at":"2025-04-12T14:55:58.755Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# glob-watcher\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nWatch globs and execute a function upon change, with intelligent defaults for debouncing and queueing.\n\n## Usage\n\n```js\nvar watch = require('glob-watcher');\n\nwatch(['./*.js', '!./something.js'], function (done) {\n  // This function will be called each time a globbed file is changed\n  // but is debounced with a 200ms delay (default) and queues subsequent calls\n\n  // Make sure to signal async completion with the callback\n  // or by returning a stream, promise, observable or child process\n  done();\n\n  // if you need access to the `path` or `stat` object, listen\n  // for the `change` event (see below)\n\n  // if you need to listen to specific events, use the returned\n  // watcher instance (see below)\n});\n\n// Raw chokidar instance\nvar watcher = watch(['./*.js', '!./something.js']);\n\n// Listen for the 'change' event to get `path`/`stat`\n// No async completion available because this is the raw chokidar instance\nwatcher.on('change', function (path, stat) {\n  // `path` is the path of the changed file\n  // `stat` is an `fs.Stat` object (not always available)\n});\n\n// Listen for other events\n// No async completion available because this is the raw chokidar instance\nwatcher.on('add', function (path, stat) {\n  // `path` is the path of the changed file\n  // `stat` is an `fs.Stat` object (not always available)\n});\n```\n\n## API\n\n### `watch(globs[, options][, fn])`\n\nTakes a path string, an array of path strings, a [glob][micromatch] string or an array of [glob][micromatch] strings as `globs` to watch on the filesystem. Also optionally takes `options` to configure the watcher and a `fn` to execute when a file changes.\n\n**Note: As of 5.0.0, globs must use `/` as the separator character because `\\\\` is reserved for escape sequences (as per the Bash 4.3 \u0026 Micromatch specs). This means you can't use `path.join()` or `**dirname`in Windows environments. If you need to use`path.join()`, you can use [normalize-path][normalize-path] against your paths afterwards. If you need to use `**dirname`, you can set it as the `cwd` option that gets passed directly to [chokidar][chokidar]. The [micromatch docs][micromatch-backslashes] contain more information about backslashes.**\n\nReturns an instance of [chokidar][chokidar].\n\n#### `fn([callback])`\n\nIf the `fn` is passed, it will be called when the watcher emits a `change`, `add` or `unlink` event. It is automatically debounced with a default delay of 200 milliseconds and subsequent calls will be queued and called upon completion. These defaults can be changed using the `options`.\n\nThe `fn` is passed a single argument, `callback`, which is a function that must be called when work in the `fn` is complete. Instead of calling the `callback` function, [async completion][async-completion] can be signalled by:\n\n- Returning a `Stream` or `EventEmitter`\n- Returning a `Child Process`\n- Returning a `Promise`\n- Returning an `Observable`\n\nOnce async completion is signalled, if another run is queued, it will be executed.\n\n#### `options`\n\n##### `options.ignoreInitial`\n\nIf set to `false` the `fn` is called during [chokidar][chokidar] instantiation as it discovers the file paths. Useful if it is desirable to trigger the `fn` during startup.\n\n**Passed through to [chokidar][chokidar], but defaulted to `true` instead of `false`.**\n\nType: `Boolean`\n\nDefault: `true`\n\n##### `options.delay`\n\nThe delay to wait before triggering the `fn`. Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files.\n\nType: `Number`\n\nDefault: `200` (milliseconds)\n\n##### `options.queue`\n\nWhether or not a file change should queue the `fn` execution if the `fn` is already running. Useful for a long running `fn`.\n\nType: `Boolean`\n\nDefault: `true`\n\n##### `options.events`\n\nAn event name or array of event names to listen for. Useful if you only need to watch specific events.\n\nType: `String | Array\u003cString\u003e`\n\nDefault: `[ 'add', 'change', 'unlink' ]`\n\n##### other\n\nOptions are passed directly to [chokidar][chokidar].\n\n## License\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/glob-watcher.svg?style=flat-square\n[npm-url]: https://npmjs.com/package/glob-watcher\n[npm-image]: https://img.shields.io/npm/v/glob-watcher.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/glob-watcher/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/glob-watcher/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/glob-watcher\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/glob-watcher/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n[micromatch]: https://github.com/micromatch/micromatch\n[normalize-path]: https://www.npmjs.com/package/normalize-path\n[micromatch-backslashes]: https://github.com/micromatch/micromatch#backslashes\n[async-completion]: https://github.com/gulpjs/async-done#completion-and-error-resolution\n[chokidar]: https://github.com/paulmillr/chokidar\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fglob-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fglob-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fglob-watcher/lists"}