@travetto/watch

2.2.4 • Public • Published

Watch

Support for making files watchable during runtime

Install: @travetto/watch

npm install @travetto/watch

This module is intended to be used during development, and is not during production. This constraint is tied to the performance hit the functionality could have at run-time. To that end, this is primarily an utility for other modules, but it's functionality could prove useful to others during development.

File Watching

This module is the base file system watching support for Travetto applications. In addition to file system scanning, the framework offers a simple file watching library. The goal is to provide a substantially smaller footprint than gaze or chokidar. Utilizing the patterns from the file scanning, you create a Watcher that either has files added manually, or has patterns added that will recursively look for files.

Code: Example of watching for specific files

import { Watcher } from '@travetto/watch';

export function main(): void {
  const watcher = new Watcher('base/path/to/...')
    .on('all', ({ event, entry }) => {
      if (entry.file.endsWith('.config') || entry.file.endsWith('.config.json')) {
        console.log('File Event', { event, file: entry.file });
      }
    });

  setTimeout(() => watcher.close(), 1000);
}

Package Sidebar

Install

npm i @travetto/watch

Homepage

travetto.io

Weekly Downloads

1

Version

2.2.4

License

MIT

Unpacked Size

14.4 kB

Total Files

8

Last publish

Collaborators

  • arcsine