3 Commits
Author SHA1 Message Date
Wez Furlong e9aacf0f00 node: switch example to use new dirname expression term
No need for pcre now that we have dirname
2015-04-05 19:33:53 -07:00
Wez Furlong 8a41272ee2 update node client example and docs to use watch-project
Summary:
Shows how you might use relative_path to compensate for the offset
in the query expression and in the subscription event handler.

Need to add an expression term to make it simpler to match under a dir prefix
so that these don't require the use of pcre.

Test Plan:
ran the example locally:

```
$ node ./example.js
Talking to watchman version 3.1.0
failed to subscribe:  { [Error: unknown command invalid-command-never-will-work]
  watchmanResponse:
   { version: '3.1.0',
     error: 'unknown command invalid-command-never-will-work' } }
(re)using project watch at  /Users/wez/fb/watchman , our dir is relative:  node/
subscription mysubscription established
/Users/wez/fb/watchman mysubscription
{ name: 'example.js', size: 5698, exists: true, type: 'f' }
{ name: 'node_modules/json-stream/test/json-stream-test.js',
  size: 1539,
  exists: true,
  type: 'f' }
{ name: 'node_modules/json-stream/test/pipe-test.js',
  size: 749,
  exists: true,
  type: 'f' }
{ name: 'node_modules/json-stream/test/throw-in-readable-test.js',
  size: 305,
  exists: true,
  type: 'f' }
{ name: 'node_modules/json-stream/lib/json-stream.js',
  size: 943,
  exists: true,
  type: 'f' }
{ name: 'node_modules/nextback/test/main.js',
  size: 1224,
  exists: true,
  type: 'f' }
{ name: 'node_modules/nextback/index.js',
  size: 229,
  exists: true,
  type: 'f' }
{ name: 'index.js', size: 5232, exists: true, type: 'f' }
subscription sincesub established
```

Reviewers: amasad, sid0

Reviewed By: sid0

Differential Revision: https://reviews.facebook.net/D36465
2015-04-03 10:55:58 -07:00
Wez Furlong ef860b0238 watchman: nodejs client bindings
Summary:
Adds a simple but powerful asynchronous binding to the watchman service.

My motivation is to allow consolidating watch resources between our
watchman-based source control and what I'm assuming is Grunt-based watching in
javascript (via gaze?).

The first step towards that is providing a client to talk to watchman and subscribe to changes.

Later steps are to look at having gaze or whichever node modules are most
heavily used in our workflows adapt to be able to consume the watchman based
watcher.

I've dabbled in nodejs in the past, but it's not my focus.  I'm looking for
suggestions on how to make this more idiomatic.  Obviously missing from this
diff is any kind of unit test.

Test Plan:
Manual:

```
cd watchman/node
npm install
npm link
npm link fb-watchman
node example.js
```

Outputs:

```
$ node example.js
Talking to watchman version 2.9.9
failed to subscribe:  { [Error: unknown command invalid-command-never-will-work]
  watchmanResponse:
   { version: '2.9.9',
     error: 'unknown command invalid-command-never-will-work' } }
subscription mysubscription established
/Users/wez/fb/watchman/node mysubscription [ { name: 'example.js',
    size: 1374,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'index.js',
    size: 3917,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/json-stream/test/json-stream-test.js',
    size: 1539,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/json-stream/test/pipe-test.js',
    size: 749,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/json-stream/test/throw-in-readable-test.js',
    size: 305,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/json-stream/lib/json-stream.js',
    size: 943,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/nextback/test/main.js',
    size: 1224,
    new: true,
    exists: true,
    mode: 33188 },
  { name: 'node_modules/nextback/index.js',
    size: 229,
    new: true,
    exists: true,
    mode: 33188 } ]
```

Reviewers: amasad, sstur

Reviewed By: amasad, sstur

Subscribers: sstur, amasad

Differential Revision: https://reviews.facebook.net/D28203
2014-11-03 13:01:50 -08:00