0.1.4 • Published 6 years ago

swordsman v0.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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.
0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago