@types/fb-watchman
- Version 2.0.5
- Published
- 15.2 kB
- 1 dependency
- MIT license
Install
npm i @types/fb-watchman
yarn add @types/fb-watchman
pnpm add @types/fb-watchman
Overview
TypeScript definitions for fb-watchman
Index
Classes
Interfaces
Type Aliases
Classes
class Client
class Client extends EventEmitter {}
constructor
constructor(options?: ClientOptions);
method cancelCommands
cancelCommands: (why: string) => void;
Cancel all pending commands
Parameter why
Reason for cancellation
method capabilityCheck
capabilityCheck: (caps: Capabilities, done: CommandCallback) => void;
Check capabilities of the watchman service
Parameter caps
Capabilities to check
Parameter done
Callback with results
method command
command: { ( args: ['watch-project', string], callback: CommandCallback<WatchProjectResponse> ): void; ( args: ['subscribe', string, string, SubscriptionConfig], callback: CommandCallback<SubscribeResponse> ): void; ( args: ['unsubscribe', string, string], callback: CommandCallback<any> ): void; (args: ['log-level', LogLevel], callback: CommandCallback<any>): void; (args: ['watch', string], callback: CommandCallback<any>): void; ( args: ['get-config', string], callback: CommandCallback<{ version: string; config: Record<string, unknown>; }> ): void; ( args: ['get-sockname'], callback: CommandCallback<{ version: string; sockname: string }> ): void; (args: ['log', LogLevel, string], callback: CommandCallback<any>): void; (args: ['shutdown-server'], callback: CommandCallback<any>): void; ( args: ['clock', string] | ['clock', string, Record<string, unknown>], callback: CommandCallback<any> ): void; ( args: ['find', string] | ['find', string, string[]], callback: CommandCallback<FileChange[]> ): void; ( args: ['state-enter', string, string | Record<string, unknown>], callback: CommandCallback<any> ): void; ( args: ['state-leave', string, string | Record<string, unknown>], callback: CommandCallback<any> ): void; ( args: | ['version'] | ['version', { optional: string[]; required: string[] }], callback: CommandCallback<{ version: string; buildinfo: string; capabilities?: Record<string, boolean>; }> ): void; ( args: ['list-capabilities'], callback: CommandCallback<{ capabilities: Record<string, boolean> }> ): void; ( args: [ ( | 'flush-subscriptions' | 'query' | 'since' | 'trigger-del' | 'trigger-list' | 'trigger' | 'watch-del-all' | 'watch-del' | 'watch-list' ), ...any[] ] ): void;};
Watch a directory
Parameter dir
Directory to watch
Parameter callback
Response callback
Subscribe to file changes
Parameter watch
Watch root from watch-project response
Parameter name
Subscription name
Parameter config
Subscription configuration
Parameter callback
Response callback
Cancel a subscription
Parameter watch
Watch root from watch-project response
Parameter name
Subscription name to cancel
Parameter callback
Response callback
log-level
Parameter level
Log level
client.command(['log-level', 'debug']); client.on('log', function(info) { console.log(info); });
Request watching a directory for changes
Parameter dir
Absolute path to directory to watch
Parameter callback
Response callback
Example 1
client.command(['watch', '/home/user/www']);
Deprecated
Since version 3.1. Use watch-project instead
Get watchman configuration for a root Returns the .watchmanconfig for the root, or empty config if none exists
Parameter root
Watch root to get config for
Parameter callback
Response callback
Get the path to the watchman socket Useful when integrating with watchman using unix socket with JSON/BSER protocol Has side effect of spawning the service if not running
Parameter callback
Response callback
Generate a log line in the watchman log
Parameter level
Log level (debug, error)
Parameter message
Message to log
Parameter callback
Response callback
Example 1
client.command(['log', 'debug', 'log this please']);
Shutdown the watchman server Causes the watchman service to exit with a normal status code
Parameter callback
Response callback
Returns the current clock value for a watched root clock-sync-timeout capability for sync_timeout option
Parameter root
Watch root to get clock for
Parameter options
Optional sync_timeout configuration
Parameter callback
Response callback
Example 1
client.command(['clock', '/path/to/dir', { sync_timeout: 100 }]);
Find files under a specified directory
Parameter root
Directory to search in
Parameter patterns
Optional patterns to filter files
Parameter callback
Response callback
Example 1
client.command(['find', '/path/to/dir']); // Find all files client.command(['find', '/path/to/dir', ['*.js', '*.ts']]); // Find by patterns
Mark a watch as being in a particular named state 4.4
Parameter root
Watch root to set state for
Parameter state
State name or configuration
Parameter callback
Response callback
The state persists until a corresponding state-leave command or until the client session disconnects. Used in conjunction with state-leave for advanced settling in subscriptions.
Example 1
// Simple state client.command(['state-enter', '/path/to/root', 'mystate']);
// Complex state with metadata and sync_timeout client.command(['state-enter', '/path/to/root', { name: 'mystate', metadata: { foo: 'bar' }, sync_timeout: 10000 }]);
Remove a particular named state from a watch 4.4
Parameter root
Watch root to remove state from
Parameter state
State name or configuration
Parameter callback
Response callback
Used in conjunction with state-enter for advanced settling in subscriptions. States are automatically removed when the client session disconnects.
Example 1
// Simple state client.command(['state-leave', '/path/to/root', 'mystate']);
// Complex state with metadata and sync_timeout client.command(['state-leave', '/path/to/root', { name: 'mystate', metadata: { foo: 'bar' }, sync_timeout: 10000 }]);
Get version and build information for the watchman service
Parameter callback
Response callback
Example 1
client.command(['version'], (error, resp) => { console.log(
Server version: ${resp.version}
); console.log(Build info: ${resp.buildinfo}
); });This command returns the full list of supported capabilities offered by the watchman server. The intention is that client applications will use the expanded version command to check compatibility rather than interrogating the full list.
Parameter callback
Response callback
There are more commands but they are not documented: https://facebook.github.io/watchman/docs/nodejs
method connect
connect: () => void;
Connect to the watchman service
method end
end: () => void;
End the connection
method on
on: { (event: 'connect', listener: () => void): this; ( event: 'subscription', listener: (resp: SubscriptionResponse) => void ): this; (event: 'error', listener: (error: Error) => void): this; (event: 'end', listener: () => void): this; ( event: 'log', listener: (info: { version: string; log: string }) => void ): this;};
Connect
Subscription event handler
Error event handler
End event handler
Log event handler
See Also
https://facebook.github.io/watchman/docs/cmd/log-level
method sendNextCommand
sendNextCommand: () => void;
Send the next command in the queue
Interfaces
interface Capabilities
interface Capabilities {}
Watchman capability check configuration
interface ClientOptions
interface ClientOptions {}
Options for configuring the Watchman client
property watchmanBinaryPath
watchmanBinaryPath?: string;
Absolute path to the watchman binary. If not provided, the Client locates the binary using the PATH specified by the node child_process's default env.
interface FileChange
interface FileChange {}
Information about a changed file
property exists
exists?: boolean;
Whether the file exists
property mtime_ms
mtime_ms?: number | { toNumber(): number };
Modification time in milliseconds since epoch
property name
name: string;
Name of the file that changed
property size
size?: number;
Size of the file in bytes
property type
type?: FileType;
Type of the file
interface SubscribeResponse
interface SubscribeResponse {}
Response from the subscribe command
property subscribe
subscribe: string;
Name of the subscription that was established
interface SubscriptionConfig
interface SubscriptionConfig {}
Subscription configuration
property expression
expression: Expression;
Expression to filter files
property fields
fields?: Array<keyof FileChange>;
Fields to include in the response
property relative_root
relative_root?: string;
Relative root for the subscription
interface SubscriptionResponse
interface SubscriptionResponse {}
File change notification from a subscription
property files
files: FileChange[];
Array of files that changed
property root
root: string;
Root directory being watched
property subscription
subscription: string;
Subscription name that generated this notification
interface WatchProjectResponse
interface WatchProjectResponse {}
Response from the watch-project command
property relative_path
relative_path?: string;
Relative path from the watch root to the requested directory
property warning
warning?: string;
Warning message if any
property watch
watch: string;
The watched root directory
Type Aliases
type CommandCallback
type CommandCallback<T = any> = (error: Error | null, resp: T) => void;
Callback type for command responses
type DepthOperator
type DepthOperator = 'eq' | 'ge' | 'gt' | 'le' | 'lt' | 'ne';
Depth operators for dirname expressions
Example 1
["dirname", "foo/bar", ["depth", "eq", 0]]
type Expression
type Expression = | readonly ['allof', ...Expression[]] | readonly ['anyof', ...Expression[]] | readonly ['not', Expression] | readonly ['true'] | readonly ['false'] | readonly ['empty'] | readonly ['exists'] | readonly ['since', string | number, TimeField?] | readonly ['size', SizeOperator, number] | readonly ['suffix', string | string[]] | readonly ['type', FileType] | readonly ['dirname', string] | readonly ['dirname', string, readonly ['depth', DepthOperator, number]] | readonly ['match', string, NameScope?] | readonly ['name', string | string[], NameScope?] | readonly ['iname', string | string[], NameScope?];
Expression term definitions
See Also
https://facebook.github.io/watchman/docs/expr/allof.html
type FileType
type FileType = 'b' | 'c' | 'd' | 'f' | 'p' | 'l' | 's' | 'D' | '?';
File type identifiers - b: block special file - c: character special file - d: directory - f: regular file - p: named pipe (fifo) - l: symbolic link - s: socket - D: Solaris Door - ?: unknown file type
type LogLevel
type LogLevel = 'debug' | 'error' | 'off';
Log Levels: - debug - receive all log events - error - receive only important log events - off - receive no log events
type NameScope
type NameScope = 'basename' | 'wholename';
Name scope for match and name expressions - basename: Match against the file's basename (default) - wholename: Match against the file's full path
type SizeOperator
type SizeOperator = 'eq' | 'ge' | 'gt' | 'le' | 'lt' | 'ne';
Size comparison operators
type TimeField
type TimeField = 'mtime' | 'ctime';
Time fields for since expressions
type UnilateralTags
type UnilateralTags = 'unilateralTags' | 'log';
Package Files (1)
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/fb-watchman
.
- Markdown[](https://www.jsdocs.io/package/@types/fb-watchman)
- HTML<a href="https://www.jsdocs.io/package/@types/fb-watchman"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3640 ms. - Missing or incorrect documentation? Open an issue for this package.