wch
Watchman client
Last updated 2 years ago by aleclarson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install wch 
SYNC missed versions from official npm registry.

wch v0.10.2

Client library for the wch daemon.

Compatible with wchd v0.10

wch(dir: string): Promise<boolean>

Track a directory indefinitely.

Resolves to true if successful.

wch.unwatch(dir: string): Promise<boolean>

Stop tracking a directory.

Resolves to true if successful.

wch.connect(): Promise<Object>

This method must be called before any other actions are processed. Whenever not connected, actions are stored in the offline queue.

If the returned promise is rejected, you need to manually call connect again if you wish to retry. Though, not all errors will reject the promise. When the wchd server is unreachable, the promise will stay pending while the client waits for the server to be restarted.

The connected and connecting properties reflect the current state of the connection.

wch.close(): void

Force disconnect from the wchd server.

wch.stream(dir: string, query: Object): Readable

Stream changes to matching paths within a directory.

The data event is emitted for every change. Listeners are passed an object representing the affected file.

The close event is emitted when the stream has its destroy method called.

The stream manages its subscription as expected whenever the client loses its connection to the server.

The stream is created by the readable-stream library to ensure reliable behavior between NodeJS versions.

Note: You should always handle error events on a stream, or your process will easily crash.

wch.query(dir: string, query: Object): Promise<Object>

Fetch matching paths within a directory.

The query argument is not yet documented.

The resolved object has the following properties:

  • root: string
  • clock: string
  • files: Object[]

Note: The dir argument must be within a tracked directory.

wch.expr(query: Object): Array

Pass a wch-style query to get the expression property of the equivalent Watchman-style query.

Note: This method doesn't communicate with the server.

wch.list(): Promise<string[]>

Fetch the list of tracked directories.

Events

In addition to events provided by plugins, there are several events provided by the client library.

connecting

The socket is attempting to connect (to the wchd server).

connect

The socket has connected. Emits on reconnect, too.

offline

The wchd server is unreachable.

close

The socket lost its connection.

error

The socket met an error.

Plugins may also use this event to broadcast errors.

Listeners are passed an Error object.

Note: You should always listen for this event.

Current Tags

  • 0.10.2                                ...           latest (2 years ago)

22 Versions

  • 0.10.2                                ...           2 years ago
  • 0.10.1                                ...           2 years ago
  • 0.10.0                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.2                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 8
Dependencies (6)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |