How to use fb-watchman - 10 common examples

To help you get started, we’ve selected a few fb-watchman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / watchman / node / example.js View on Github external
var watchman = require('fb-watchman');
var client = new watchman.Client();

client.on('end', function() {
  // Called when the connection to watchman is terminated
  console.log('client ended');
});

client.on('error', function(error) {
  console.error('Error while talking to watchman: ', error);
});

client.capabilityCheck({required:['relative_root']}, function (error, resp) {
  if (error) {
    console.error('Error checking capabilities:', error);
    return;
  }
  console.log('Talking to watchman version', resp.version);
github markis / watchman-processor / src / ioc.config.ts View on Github external
import { Container } from 'inversify';
import * as interfaces from '../interfaces';
import { CliImpl } from './Cli';
import { ConfigManagerImpl } from './ConfigManager';
import { Bindings } from './ioc.bindings';
import { SyncImpl } from './Sync';
import { TerminalImpl } from './Terminal';
import { WatchmanProcessorImpl } from './WatchmanProcessor';

const container = new Container();

// setup core functionality and externals
container.bind(Bindings.Process).toConstantValue(process);
container.bind(Bindings.Spawn).toConstantValue(spawn);
container.bind(Bindings.Require).toConstantValue(require);
container.bind(Bindings.WatchmanClient).toConstantValue(new Client());

// setup the main classes
container.bind(Bindings.Cli).to(CliImpl);
container.bind(Bindings.ConfigManager).to(ConfigManagerImpl);
container.bind(Bindings.Config).toDynamicValue(() => {
  return container.get(Bindings.ConfigManager).getConfig() as any;
});
container.bind(Bindings.Terminal).to(TerminalImpl);
container.bind(Bindings.Sync).to(SyncImpl);
container.bind(Bindings.WatchmanProcessor).to(WatchmanProcessorImpl);

export { container };
github amasad / sane / src / watchman_client.js View on Github external
return new Promise((resolve, reject) => {
      let client;

      try {
        client = new watchman.Client(
          this._watchmanBinaryPath
            ? { watchmanBinaryPath: this._watchmanBinaryPath }
            : {}
        );
      } catch (error) {
        // if we're here, either the binary path is bad or something
        // else really bad happened. The client doesn't even attempt
        // to connect until we send it a command, though.
        reject(error);
        return;
      }

      client.on('error', error => {
        client.removeAllListeners();
        reject(error);
      });
github facebook / watchman / tests / integration / case.js View on Github external
var assert = require('assert');
var watchman = require('fb-watchman');
var client = new watchman.Client();
const fs = require('fs');
const os = require('os');
const path = require('path');

var platform = os.platform();
if (platform == 'darwin' || platform == 'win32') {
  var tmp = fs.realpathSync(process.env.TMPDIR);
  var foo = path.join(tmp, 'foo');
  var FOO = path.join(tmp, 'FOO');

  fs.mkdir(FOO, function(err_mk_dir_foo) {
    assert.equal(err_mk_dir_foo, null, 'no errors');
    var bar = path.join(foo, 'bar');
    var BAR = path.join(FOO, 'bar');

    fs.mkdir(BAR, function(err_mk_dir_bar) {
github facebook / watchman / tests / integration / capabilities.js View on Github external
function required() {
  var client = new watchman.Client();
  client.capabilityCheck({required: ['will-never-exist']},
      function (error, resp) {
        assert.equal('client required capability `will-never-exist` is not' +
                     ' supported by this server', error.message);
        client.end();
      });
}
required();
github Shopify / graphql-js-client / scripts / watcher.js View on Github external
function createClient() {
  const client = new watchman.Client();

  client.on('end', () => {
    logInfo('client ended');
  });

  client.on('error', (error) => {
    console.log(error);
    handleFatalError('Error while talking to watchman: ', error);
  });

  return client;
}
github facebook / relay / packages / relay-compiler / core / GraphQLWatchmanClient.js View on Github external
async command(...args: Array): Promise {
    let attempt = 0;
    while (true) {
      try {
        attempt++;
        return await this._command(...args);
      } catch (error) {
        if (attempt > this._attemptLimit) {
          throw error;
        }
        await delay(Math.pow(2, attempt) * 500);
        this._client.end();
        this._client = new watchman.Client();
      }
    }
  }
github researchgate / webpack-watchman-plugin / src / WatchmanConnector.js View on Github external
getClientInstance(): Client {
        if (!this.client) {
            const client = new Client();
            client.on('connect', () => {
                this.connected = true;
            });
            client.on('end', () => {
                this.connected = false;
            });

            this.client = client;
        }

        return this.client;
    }
github postlight / lux / src / packages / fs / watcher / initialize.js View on Github external
return new Promise((resolve, reject) => {
    const client = new Watchman()

    client.capabilityCheck({}, (capabilityErr) => {
      if (capabilityErr) {
        reject(capabilityErr)
        return
      }

      client.command(['watch-project', path], (watchErr, {
        watch,
        relative_path: relativePath
      } = {}) => {
        if (watchErr) {
          reject(watchErr)
          return
        }
github facebook / relay / packages / relay-compiler / core / GraphQLWatchmanClient.js View on Github external
constructor(attemptLimit: number = 0) {
    this._client = new watchman.Client();
    this._attemptLimit = Math.max(Math.min(MAX_ATTEMPT_LIMIT, attemptLimit), 0);
  }

fb-watchman

Bindings for the Watchman file watching service

MIT
Latest version published 2 years ago

Package Health Score

88 / 100
Full package analysis

Popular fb-watchman functions