8000 GitHub - wuha-team/swordsman: Sharp file watch interface for Facebook Watchman
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wuha-team/swordsman

Repository files navigation

Swordsman ⚔️

Build Status Coverage Status npm

Swordsman is a file watch interface for Facebook Watchman. The goal is to provide an easy to use API to leverage all the power of Watchman in NodeJS. It is heavily inspired by sane, but focused exclusively on Watchman.

Install

npm install swordsman

Usage

import { Stats } from 'fs'
import * as swordsman from 'swordsman'

const watcher = new sworsdman.Watcher('/path/to/watch')

watcher.on('ready', () => { console.log('ready') })
watcher.on('add', (path: string, stats: Stats) => { console.log('file added', path, stats) })
watcher.on('change', (path: string, stats: Stats) => { console.log('file changed', path, stats) })
watcher.on('delete', (path: string) => { console.log('file deleted', path) })

watcher.close().then(() => { console.log('watcher closed') })

By default, every files and directories are reported. To filter the watched files, use the Watchman query language. For example, to watch only .js files:

const watcher = new sworsdman.Watcher(
  '/path/to/watch',
  {
    expression: [
      'allof',
      [ 'type', 'f' ],
      [ 'suffix', 'js' ]
    ]
  }
)

Options

You can provide options object as a third parameter to the swordsman.Watcher constructor.

  • watchmanBinaryPath (string): Path to the Watchman binary.
  • reportExistingFiles (boolean, default false): Whether to send an ADD event for existing files on watch initialization.

About

Sharp file watch interface for Facebook Watchman

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0