New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nuclide-watchman-helpers

Package Overview
Dependencies
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuclide-watchman-helpers - npm Package Compare versions

Comparing version 0.0.35 to 0.5.0

lib/path.js

63

lib/main.js

@@ -1,55 +0,18 @@

/*
* Copyright (c) 2015-present, Facebook, Inc.
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
var getWatchmanBinaryPath = _asyncToGenerator(function* () {
try {
var stats = yield fsPromise.stat(WATCHMAN_DEFAULT_PATH);
// `stats` contains a `mode` property, a number which can be used to determine
// whether this file is executable. However, the number is platform-dependent.
if (stats && stats.isFile()) {
return WATCHMAN_DEFAULT_PATH;
}
} catch (e) {}
// Suppress the error.
import type {FileChange} from './WatchmanClient';
import WatchmanClient from './WatchmanClient';
import WatchmanSubscription from './WatchmanSubscription';
// Let the watchman Client find the watchman binary via the default env PATH.
return 'watchman';
});
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(null, 'next'); var callThrow = step.bind(null, 'throw'); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; }
var _require = require('nuclide-commons');
var fsPromise = _require.fsPromise;
var WATCHMAN_DEFAULT_PATH = '/usr/local/bin/watchman';
module.exports = Object.defineProperties({
getWatchmanBinaryPath: getWatchmanBinaryPath
}, {
WatchmanClient: {
get: function get() {
return require('./WatchmanClient');
},
configurable: true,
enumerable: true
},
WatchmanSubscription: {
// Exposed for testing.
get: function get() {
return require('./WatchmanSubscription');
},
configurable: true,
enumerable: true
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi92YXIvZm9sZGVycy94Zi9yc3BoNF9jNTczMTVyczU3eHhzZHNrcnhudjM2dDAvVC90bXBwZmw1Mm5wdWJsaXNoX3BhY2thZ2VzL25wbS9udWNsaWRlLXdhdGNobWFuLWhlbHBlcnMvbGliL21haW4uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsV0FBVyxDQUFDOzs7Ozs7Ozs7O0lBZUcscUJBQXFCLHFCQUFwQyxhQUF3RDtBQUN0RCxNQUFJO0FBQ0YsUUFBTSxLQUFLLEdBQUcsTUFBTSxTQUFTLENBQUMsSUFBSSxDQUFDLHFCQUFxQixDQUFDLENBQUM7OztBQUcxRCxRQUFJLEtBQUssSUFBSSxLQUFLLENBQUMsTUFBTSxFQUFFLEVBQUU7QUFDM0IsYUFBTyxxQkFBcUIsQ0FBQztLQUM5QjtHQUNGLENBQUMsT0FBTyxDQUFDLEVBQUUsRUFFWDs7OztBQUFBLEFBRUQsU0FBTyxVQUFVLENBQUM7Q0FDbkI7Ozs7ZUFqQm1CLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQzs7SUFBdkMsU0FBUyxZQUFULFNBQVM7O0FBRWhCLElBQU0scUJBQXFCLEdBQUcseUJBQXlCLENBQUM7O0FBaUJ4RCxNQUFNLENBQUMsT0FBTywyQkFBRztBQUNmLHVCQUFxQixFQUFyQixxQkFBcUI7O0NBVXRCO0FBUkssZ0JBQWM7U0FBQSxlQUFHO0FBQ25CLGFBQU8sT0FBTyxDQUFDLGtCQUFrQixDQUFDLENBQUM7S0FDcEM7Ozs7QUFHRyxzQkFBb0I7Ozs7U0FBQSxlQUFHO0FBQ3pCLGFBQU8sT0FBTyxDQUFDLHdCQUF3QixDQUFDLENBQUM7S0FDMUM7Ozs7RUFDRixDQUFDIiwiZmlsZSI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zICYmIHN0YXRzLmlzRmlsZSgpKSB7XG4gICAgICByZXR1cm4gV0FUQ0hNQU5fREVGQVVMVF9QQVRIO1xuICAgIH1cbiAgfSBjYXRjaCAoZSkge1xuICAgIC8vIFN1cHByZXNzIHRoZSBlcnJvci5cbiAgfVxuICAvLyBMZXQgdGhlIHdhdGNobWFuIENsaWVudCBmaW5kIHRoZSB3YXRjaG1hbiBiaW5hcnkgdmlhIHRoZSBkZWZhdWx0IGVudiBQQVRILlxuICByZXR1cm4gJ3dhdGNobWFuJztcbn1cblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gIGdldFdhdGNobWFuQmluYXJ5UGF0aCxcblxuICBnZXQgV2F0Y2htYW5DbGllbnQoKSB7XG4gICAgcmV0dXJuIHJlcXVpcmUoJy4vV2F0Y2htYW5DbGllbnQnKTtcbiAgfSxcblxuICAvLyBFeHBvc2VkIGZvciB0ZXN0aW5nLlxuICBnZXQgV2F0Y2htYW5TdWJzY3JpcHRpb24oKSB7XG4gICAgcmV0dXJuIHJlcXVpcmUoJy4vV2F0Y2htYW5TdWJzY3JpcHRpb24nKTtcbiAgfSxcbn07XG4iXX0=
export type {FileChange};
export {WatchmanClient, WatchmanSubscription};

@@ -1,294 +0,302 @@

Object.defineProperty(exports, '__esModule', {
value: true
});
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
import nuclideUri from 'nuclide-commons/nuclideUri';
import watchman from 'fb-watchman';
import {serializeAsyncCall, sleep} from 'nuclide-commons/promise';
import {maybeToString} from 'nuclide-commons/string';
import {getWatchmanBinaryPath} from './path';
import WatchmanSubscription from './WatchmanSubscription';
import {getLogger} from 'log4js';
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
const logger = getLogger('nuclide-watchman-helpers');
const WATCHMAN_SETTLE_TIME_MS = 2500;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(null, 'next'); var callThrow = step.bind(null, 'throw'); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; }
import type {WatchmanSubscriptionOptions} from './WatchmanSubscription';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
type WatchmanSubscriptionResponse = {
root: string,
subscription: string,
files?: Array<FileChange>,
'state-enter'?: string,
'state-leave'?: string,
metadata?: Object,
canceled?: boolean,
};
var _WatchmanSubscription = require('./WatchmanSubscription');
export type FileChange = {
name: string,
new: boolean,
exists: boolean,
mode: number,
};
var _WatchmanSubscription2 = _interopRequireDefault(_WatchmanSubscription);
export default class WatchmanClient {
_subscriptions: Map<string, WatchmanSubscription>;
_clientPromise: Promise<watchman.Client>;
_serializedReconnect: () => Promise<void>;
'use babel';
constructor() {
this._initWatchmanClient();
this._serializedReconnect = serializeAsyncCall(() =>
this._reconnectClient(),
);
this._subscriptions = new Map();
}
/*
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
async dispose(): Promise<void> {
const client = await this._clientPromise;
client.removeAllListeners(); // disable reconnection
client.end();
}
var watchman = require('fb-watchman');
async _initWatchmanClient(): Promise<void> {
this._clientPromise = this._createClientPromise();
var isEmpty = require('nuclide-commons').object.isEmpty;
const client = await this._clientPromise;
client.on('end', () => {
logger.info('Watchman client ended');
client.removeAllListeners();
this._serializedReconnect();
});
client.on('error', error => {
logger.error('Error while talking to watchman: ', error);
// If Watchman encounters an error in the middle of a command, it may never finish!
// The client must be immediately killed here so that the command fails and
// `serializeAsyncCall` can be unblocked. Otherwise, we end up in a deadlock.
client.removeAllListeners();
client.end();
// Those are errors in deserializing a stream of changes.
// The only possible recovery here is reconnecting a new client,
// but the failed to serialize events will be missed.
// t9353878
this._serializedReconnect();
});
client.on('subscription', this._onSubscriptionResult.bind(this));
}
var logger = require('nuclide-logging').getLogger();
async _createClientPromise(): Promise<watchman.Client> {
return new watchman.Client({
watchmanBinaryPath: await getWatchmanBinaryPath(),
});
}
var _require = require('./main');
async _reconnectClient(): Promise<void> {
logger.error('Watchman client disconnected, reconnecting a new client!');
await this._initWatchmanClient();
logger.info('Watchman client re-initialized, restoring subscriptions');
await this._restoreSubscriptions();
}
var getWatchmanBinaryPath = _require.getWatchmanBinaryPath;
async _restoreSubscriptions(): Promise<void> {
const watchSubscriptions = Array.from(this._subscriptions.values());
await Promise.all(
watchSubscriptions.map(async (subscription: WatchmanSubscription) => {
await this._watchProject(subscription.path);
// We have already missed the change events from the disconnect time,
// watchman could have died, so the last clock result is not valid.
await sleep(WATCHMAN_SETTLE_TIME_MS);
// Register the subscriptions after the filesystem settles.
subscription.options.since = await this._clock(subscription.root);
await this._subscribe(
subscription.root,
subscription.name,
subscription.options,
);
}),
);
}
var path = require('path');
_getSubscription(entryPath: string): ?WatchmanSubscription {
return this._subscriptions.get(nuclideUri.normalize(entryPath));
}
var WatchmanClient = (function () {
function WatchmanClient() {
_classCallCheck(this, WatchmanClient);
_setSubscription(
entryPath: string,
subscription: WatchmanSubscription,
): void {
this._subscriptions.set(nuclideUri.normalize(entryPath), subscription);
}
this._initWatchmanClient();
this._subscriptions = Object.create(null);
this._watchmanVersionPromise = this.version();
_deleteSubscription(entryPath: string): void {
this._subscriptions.delete(nuclideUri.normalize(entryPath));
}
_createClass(WatchmanClient, [{
key: 'dispose',
value: function dispose() {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this._clientPromise) {
_this._clientPromise.then(function (client) {
client.once('end', function () {
resolve();
});
client.end();
});
} else {
reject();
}
});
_onSubscriptionResult(response: WatchmanSubscriptionResponse): void {
const subscription = this._getSubscription(response.subscription);
if (subscription == null) {
logger.error('Subscription not found for response:!', response);
return;
}
}, {
key: '_initWatchmanClient',
value: function _initWatchmanClient() {
var _this2 = this;
this._clientPromise = this._createClientPromise();
this._clientPromise.then(function (client) {
client.on('end', function () {
return _this2._onClientEnd();
});
client.on('error', function (error) {
return logger.error('Error while talking to watchman: ', error);
});
client.on('subscription', function (response) {
return _this2._onSubscriptionResult(response);
});
});
if (!Array.isArray(response.files)) {
if (response.canceled === true) {
logger.info(`Watch for ${response.root} was deleted.`);
// Ending the client will trigger a reconnect.
this._clientPromise.then(client => client.end());
return;
}
// TODO(most): use state messages to decide on when to send updates.
const stateEnter = response['state-enter'];
const stateLeave = response['state-leave'];
const stateMessage =
stateEnter != null
? `Entering ${stateEnter}`
: `Leaving ${maybeToString(stateLeave)}`;
logger.info(`Subscription state: ${stateMessage}`);
return;
}
}, {
key: '_createClientPromise',
value: _asyncToGenerator(function* () {
return new watchman.Client({
watchmanBinaryPath: yield getWatchmanBinaryPath()
});
})
}, {
key: '_onClientEnd',
value: function _onClientEnd() {
logger.warn('Watchman client ended, creating a new client!');
this._clientPromise.then(function (client) {
client.removeAllListeners('end');
client.removeAllListeners('error');
client.removeAllListeners('subscription');
});
this._initWatchmanClient();
this._restoreSubscriptions();
}
}, {
key: '_restoreSubscriptions',
value: _asyncToGenerator(function* () {
var _this3 = this;
subscription.emit('change', response.files);
}
var watchSubscriptions = [];
for (var _key in this._subscriptions) {
watchSubscriptions.push(this._subscriptions[_key]);
async watchDirectoryRecursive(
localDirectoryPath: string,
subscriptionName?: string = localDirectoryPath,
subscriptionOptions?: WatchmanSubscriptionOptions,
): Promise<WatchmanSubscription> {
const existingSubscription = this._getSubscription(subscriptionName);
if (existingSubscription) {
existingSubscription.subscriptionCount++;
return existingSubscription;
} else {
const {
watch: watchRoot,
relative_path: relativePath,
} = await this._watchProject(localDirectoryPath);
const clock = await this._clock(watchRoot);
const options: WatchmanSubscriptionOptions = {
...subscriptionOptions,
fields: ['name', 'new', 'exists', 'mode'],
since: clock,
};
if (relativePath && !options.expression) {
options.relative_root = relativePath;
}
yield Promise.all(watchSubscriptions.map(_asyncToGenerator(function* (subscription) {
subscription.options.since = yield _this3._clock(subscription.root);
yield _this3._watchProject(subscription.path);
yield _this3._subscribe(subscription.root, subscription.name, subscription.options);
})));
})
}, {
key: '_getSubscription',
value: function _getSubscription(entryPath) {
return this._subscriptions[path.normalize(entryPath)];
}
}, {
key: '_setSubscription',
value: function _setSubscription(entryPath, subscription) {
this._subscriptions[path.normalize(entryPath)] = subscription;
// Try this thing out where we always set empty_on_fresh_instance. Eden will be a lot happier
// if we never ask Watchman to do something that results in a glob(**) near the root.
options.empty_on_fresh_instance = true;
// relativePath is undefined if watchRoot is the same as directoryPath.
const subscription = new WatchmanSubscription(
/* subscriptionRoot */ watchRoot,
/* pathFromSubscriptionRootToSubscriptionPath */ relativePath,
/* subscriptionPath */ localDirectoryPath,
/* subscriptionName */ subscriptionName,
/* subscriptionCount */ 1,
/* subscriptionOptions */ options,
);
this._setSubscription(subscriptionName, subscription);
await this._subscribe(watchRoot, subscriptionName, options);
return subscription;
}
}, {
key: '_deleteSubscription',
value: function _deleteSubscription(entryPath) {
delete this._subscriptions[path.normalize(entryPath)];
}
}, {
key: '_onSubscriptionResult',
value: function _onSubscriptionResult(response) {
var subscription = this._getSubscription(response.subscription);
if (!subscription) {
return logger.error('Subscription not found for response:!', response);
}
subscription.emit('change', response.files);
}
}, {
key: 'watchDirectoryRecursive',
value: _asyncToGenerator(function* (localDirectoryPath) {
var existingSubscription = this._getSubscription(localDirectoryPath);
if (existingSubscription) {
existingSubscription.subscriptionCount++;
return existingSubscription;
} else {
var _ref = yield this._watchProject(localDirectoryPath);
}
var watchRoot = _ref.watch;
var relativePath = _ref.relative_path;
hasSubscription(entryPath: string): boolean {
return Boolean(this._getSubscription(entryPath));
}
var clock = yield this._clock(watchRoot);
var options = {
fields: ['name', 'new', 'exists', 'mode'],
since: clock
};
if (relativePath) {
// Passing an 'undefined' expression causes an exception in fb-watchman.
options.expression = ['dirname', relativePath];
}
// relativePath is undefined if watchRoot is the same as directoryPath.
var _subscription = this._setSubscription(localDirectoryPath, new _WatchmanSubscription2['default'](
/*subscriptionRoot*/watchRoot,
/*pathFromSubscriptionRootToSubscriptionPath*/relativePath,
/*subscriptionPath*/localDirectoryPath,
/*subscriptionCount*/1,
/*subscriptionOptions*/options));
yield this._subscribe(watchRoot, localDirectoryPath, options);
return _subscription;
}
})
}, {
key: 'hasSubscription',
value: function hasSubscription(entryPath) {
return !!this._getSubscription(entryPath);
async unwatch(entryPath: string): Promise<void> {
const subscription = this._getSubscription(entryPath);
if (subscription == null) {
logger.error('No watcher entity found with path:', entryPath);
return;
}
}, {
key: 'unwatch',
value: _asyncToGenerator(function* (entryPath) {
var subscription = this._getSubscription(entryPath);
if (!subscription) {
return logger.error('No watcher entity found with path:', entryPath);
}
if (--subscription.subscriptionCount === 0) {
await this._unsubscribe(subscription.path, subscription.name);
this._deleteSubscription(entryPath);
}
}
if (--subscription.subscriptionCount === 0) {
/**
* List all (watched) files in the given directory.
* Paths will be relative.
*/
async listFiles(
entryPath: string,
options?: {[name: string]: any} = {},
): Promise<Array<string>> {
const {watch, relative_path} = await this._watchProject(entryPath);
const result = await this._command('query', watch, {
expression: [
'allof',
['type', 'f'], // all files
['exists'],
],
// Providing `path` will let watchman use path generator, and will perform
// a tree walk with respect to the relative_root and path provided.
// Path generator will do less work unless the root path of the repository
// is passed in as an entry path.
path: [''],
fields: ['name'], // names only
relative_root: relative_path,
...options,
});
return result.files;
}
yield this._unsubscribe(subscription.path, subscription.name);
// Don't delete the watcher if there are other users for it.
if (!subscription.pathFromSubscriptionRootToSubscriptionPath) {
yield this._deleteWatcher(entryPath);
}
this._deleteSubscription(entryPath);
async _watchList(): Promise<Array<string>> {
const {roots} = await this._command('watch-list');
return roots;
}
if (isEmpty(this._subscriptions)) {
yield this.dispose();
}
}
})
}, {
key: '_watchList',
value: _asyncToGenerator(function* () {
var _ref2 = yield this._command('watch-list');
_unsubscribe(
subscriptionPath: string,
subscriptionName: string,
): Promise<any> {
return this._command('unsubscribe', subscriptionPath, subscriptionName);
}
var roots = _ref2.roots;
return roots;
})
}, {
key: '_deleteWatcher',
value: function _deleteWatcher(entryPath) {
return this._command('watch-del', entryPath);
async _watch(directoryPath: string): Promise<any> {
const response = await this._command('watch', directoryPath);
if (response.warning) {
logger.error('watchman warning: ', response.warning);
}
}, {
key: '_unsubscribe',
value: function _unsubscribe(subscriptionPath, subscriptionName) {
return this._command('unsubscribe', subscriptionPath, subscriptionName);
}
}, {
key: '_watch',
value: _asyncToGenerator(function* (directoryPath) {
var response = yield this._command('watch', directoryPath);
if (response.warning) {
logger.warn('watchman warning: ', response.warning);
}
})
}, {
key: '_watchProject',
value: _asyncToGenerator(function* (directoryPath) {
var watchmanVersion = yield this._watchmanVersionPromise;
if (!watchmanVersion || watchmanVersion < '3.1.0') {
throw new Error('Watchman version: ' + watchmanVersion + ' does not support watch-project');
}
var response = yield this._command('watch-project', directoryPath);
if (response.warning) {
logger.warn('watchman warning: ', response.warning);
}
return response;
})
}, {
key: '_clock',
value: _asyncToGenerator(function* (directoryPath) {
var _ref3 = yield this._command('clock', directoryPath);
}
var clock = _ref3.clock;
return clock;
})
}, {
key: 'version',
value: _asyncToGenerator(function* () {
var _ref4 = yield this._command('version');
var version = _ref4.version;
return version;
})
}, {
key: '_subscribe',
value: function _subscribe(watchRoot, subscriptionName, options) {
return this._command('subscribe', watchRoot, subscriptionName, options);
async _watchProject(directoryPath: string): Promise<any> {
const response = await this._command('watch-project', directoryPath);
if (response.warning) {
logger.error('watchman warning: ', response.warning);
}
return response;
}
/*
* Promisify calls to watchman client.
*/
}, {
key: '_command',
value: function _command() {
var _this4 = this;
async _clock(directoryPath: string): Promise<string> {
const {clock} = await this._command('clock', directoryPath);
return clock;
}
for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) {
args[_key2] = arguments[_key2];
}
_subscribe(
watchRoot: string,
subscriptionName: ?string,
options: WatchmanSubscriptionOptions,
): Promise<WatchmanSubscription> {
return this._command('subscribe', watchRoot, subscriptionName, options);
}
return new Promise(function (resolve, reject) {
_this4._clientPromise.then(function (client) {
client.command(args, function (error, response) {
return error ? reject(error) : resolve(response);
});
})['catch'](reject);
});
}
}]);
return WatchmanClient;
})();
module.exports = WatchmanClient;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi92YXIvZm9sZGVycy94Zi9yc3BoNF9jNTczMTVyczU3eHhzZHNrcnhudjM2dDAvVC90bXBwZmw1Mm5wdWJsaXNoX3BhY2thZ2VzL25wbS9udWNsaWRlLXdhdGNobWFuLWhlbHBlcnMvbGliL1dhdGNobWFuQ2xpZW50LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztvQ0FrQmlDLHdCQUF3Qjs7OztBQWxCekQsV0FBVyxDQUFDOzs7Ozs7Ozs7O0FBV1osSUFBTSxRQUFRLEdBQUcsT0FBTyxDQUFDLGFBQWEsQ0FBQyxDQUFDOztJQUVqQyxPQUFPLEdBQUksT0FBTyxDQUFDLGlCQUFpQixDQUFDLENBQUMsTUFBTSxDQUE1QyxPQUFPOztBQUNkLElBQU0sTUFBTSxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDLFNBQVMsRUFBRSxDQUFDOztlQUN0QixPQUFPLENBQUMsUUFBUSxDQUFDOztJQUExQyxxQkFBcUIsWUFBckIscUJBQXFCOztBQUM1QixJQUFNLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSx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XG4gIH1cblxuICBfc3Vic2NyaWJlKFxuICAgICAgICB3YXRjaFJvb3Q6IHN0cmluZyxcbiAgICAgICAgc3Vic2NyaXB0aW9uTmFtZTogP3N0cmluZyxcbiAgICAgICAgb3B0aW9uczogV2F0Y2htYW5TdWJzY3JpcHRpb25PcHRpb25zXG4gICAgICApOiBQcm9taXNlPFdhdGNobWFuU3Vic2NyaXB0aW9uPiB7XG4gICAgcmV0dXJuIHRoaXMuX2NvbW1hbmQoJ3N1YnNjcmliZScsIHdhdGNoUm9vdCwgc3Vic2NyaXB0aW9uTmFtZSwgb3B0aW9ucyk7XG4gIH1cblxuICAvKlxuICAgKiBQcm9taXNpZnkgY2FsbHMgdG8gd2F0Y2htYW4gY2xpZW50LlxuICAgKi9cbiAgX2NvbW1hbmQoLi4uYXJnczogQXJyYXk8YW55Pik6IFByb21pc2U8YW55PiB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIHRoaXMuX2NsaWVudFByb21pc2UudGhlbihjbGllbnQgPT4ge1xuICAgICAgICBjbGllbnQuY29tbWFuZChhcmdzLCAoZXJyb3IsIHJlc3BvbnNlKSA9PlxuICAgICAgICAgICAgZXJyb3IgPyByZWplY3QoZXJyb3IpIDogcmVzb2x2ZShyZXNwb25zZSkpO1xuICAgICAgfSkuY2F0Y2gocmVqZWN0KTtcbiAgICB9KTtcbiAgfVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IFdhdGNobWFuQ2xpZW50O1xuIl19
/*
* Promisify calls to watchman client.
*/
_command(...args: Array<any>): Promise<any> {
return new Promise((resolve, reject) => {
this._clientPromise
.then(client => {
client.command(
args,
(error, response) => (error ? reject(error) : resolve(response)),
);
})
.catch(reject);
});
}
}

@@ -1,25 +0,37 @@

/*
* Copyright (c) 2015-present, Facebook, Inc.
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
Object.defineProperty(exports, '__esModule', {
value: true
});
import {Emitter} from 'event-kit';
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
export type WatchmanSubscriptionOptions = {
expression: ?Array<string>, // e.g. ['match', '*.js'],
fields?: Array<string>, // e.g. ['name', 'size', 'exists', 'mode']
expression?: Array<mixed>, // e.g. ['dirname', relativePath]
since?: string, // e.g. "c:1439492655:58601:1:14195"
defer_vcs?: boolean,
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/**
* For performance reasons, prefer:
*
* "relative_root": "relative/path"
*
* over:
*
* "expression": ["dirname", "relative/path"]
*/
relative_root?: string,
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/** If true, no files will be returned for fresh instances. */
empty_on_fresh_instance?: boolean,
};
var _require = require('events');
var EventEmitter = _require.EventEmitter;
// e.g. "c:1439492655:58601:1:14195"
/**

@@ -32,24 +44,25 @@ * @param pathFromSubscriptionRootToSubscriptionPath The relative path from

*/
var WatchmanSubscription = (function (_EventEmitter) {
_inherits(WatchmanSubscription, _EventEmitter);
function WatchmanSubscription(subscriptionRoot, pathFromSubscriptionRootToSubscriptionPath, subscriptionPath, subscriptionCount, subscriptionOptions) {
_classCallCheck(this, WatchmanSubscription);
_get(Object.getPrototypeOf(WatchmanSubscription.prototype), 'constructor', this).call(this);
export default class WatchmanSubscription extends Emitter {
subscriptionCount: number;
root: string;
path: string;
pathFromSubscriptionRootToSubscriptionPath: ?string;
name: string;
options: WatchmanSubscriptionOptions;
constructor(
subscriptionRoot: string,
pathFromSubscriptionRootToSubscriptionPath: ?string,
subscriptionPath: string,
subscriptionName: string,
subscriptionCount: number,
subscriptionOptions: WatchmanSubscriptionOptions,
) {
super();
this.root = subscriptionRoot;
this.pathFromSubscriptionRootToSubscriptionPath = pathFromSubscriptionRootToSubscriptionPath;
this.path = this.name = subscriptionPath;
this.path = subscriptionPath;
this.name = subscriptionName;
this.subscriptionCount = subscriptionCount;
this.options = subscriptionOptions;
}
return WatchmanSubscription;
})(EventEmitter);
module.exports = WatchmanSubscription;
// e.g. ['match', '*.js'],
// e.g. ['name', 'size', 'exists', 'mode']
// e.g. ['dirname', relativePath]
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi92YXIvZm9sZGVycy94Zi9yc3BoNF9jNTczMTVyczU3eHhzZHNrcnhudjM2dDAvVC90bXBwZmw1Mm5wdWJsaXNoX3BhY2thZ2VzL25wbS9udWNsaWRlLXdhdGNobWFuLWhlbHBlcnMvbGliL1dhdGNobWFuU3Vic2NyaXB0aW9uLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLFdBQVcsQ0FBQzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7ZUFXVyxPQUFPLENBQUMsUUFBUSxDQUFDOztJQUFqQyxZQUFZLFlBQVosWUFBWTs7Ozs7Ozs7Ozs7SUFnQmIsb0JBQW9CO1lBQXBCLG9CQUFvQjs7QUFPYixXQVBQLG9CQUFvQixDQVFwQixnQkFBd0Is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XRoOiBzdHJpbmc7XG4gIHBhdGhGcm9tU3Vic2NyaXB0aW9uUm9vdFRvU3Vic2NyaXB0aW9uUGF0aDogP3N0cmluZztcbiAgbmFtZTogc3RyaW5nO1xuICBvcHRpb25zOiBXYXRjaG1hblN1YnNjcmlwdGlvbk9wdGlvbnM7XG4gIGNvbnN0cnVjdG9yKFxuICAgICAgc3Vic2NyaXB0aW9uUm9vdDogc3RyaW5nLFxuICAgICAgcGF0aEZyb21TdWJzY3JpcHRpb25Sb290VG9TdWJzY3JpcHRpb25QYXRoOiA/c3RyaW5nLFxuICAgICAgc3Vic2NyaXB0aW9uUGF0aDogc3RyaW5nLFxuICAgICAgc3Vic2NyaXB0aW9uQ291bnQ6IG51bWJlcixcbiAgICAgIHN1YnNjcmlwdGlvbk9wdGlvbnM6IFdhdGNobWFuU3Vic2NyaXB0aW9uT3B0aW9uc1xuICAgICAgKSB7XG4gICAgc3VwZXIoKTtcbiAgICB0aGlzLnJvb3QgPSBzdWJzY3JpcHRpb25Sb290O1xuICAgIHRoaXMucGF0aEZyb21TdWJzY3JpcHRpb25Sb290VG9TdWJzY3JpcHRpb25QYXRoID0gcGF0aEZyb21TdWJzY3JpcHRpb25Sb290VG9TdWJzY3JpcHRpb25QYXRoO1xuICAgIHRoaXMucGF0aCA9IHRoaXMubmFtZSA9IHN1YnNjcmlwdGlvblBhdGg7XG4gICAgdGhpcy5zdWJzY3JpcHRpb25Db3VudCA9IHN1YnNjcmlwdGlvbkNvdW50O1xuICAgIHRoaXMub3B0aW9ucyA9IHN1YnNjcmlwdGlvbk9wdGlvbnM7XG4gIH1cbn1cbm1vZHVsZS5leHBvcnRzID0gV2F0Y2htYW5TdWJzY3JpcHRpb247XG4iXX0=
}
{
"dependencies": {
"fb-watchman": "1.1.0",
"nuclide-commons": "0.0.35",
"nuclide-logging": "0.0.35"
},
"name": "nuclide-watchman-helpers",
"publisher": "Facebook",
"main": "./lib/main.js",
"version": "0.5.0",
"description": "Helper methods for interacting with fb-watchman",
"devDependencies": {
"nuclide-jasmine": "0.0.35",
"temp": "0.8.3"
},
"license": "SEE LICENSE IN LICENSE",
"main": "./lib/main",
"name": "nuclide-watchman-helpers",
"author": "NEEDS OWNER",
"license": "BSD-3-Clause",
"nuclide": {
"excludeTestsFromContinuousIntegration": true,
"packageType": "Node",
"testsCannotBeRunInParallel": true,
"testRunner": "npm"
},
"repository": "https://github.com/facebook/nuclide",
"repository": "https://github.com/facebook/nuclide/tree/master/modules/nuclide-watchman-helpers",
"scripts": {
"test": "node --harmony node_modules/.bin/jasmine-node-transpiled spec"
"test": "node ../nuclide-jasmine/bin/jasmine-node-transpiled spec"
},
"version": "0.0.35"
"dependencies": {
"async-to-generator": "1.1.0",
"event-kit": "2.2.0",
"fb-watchman": "2.0.0",
"log4js": "1.1.1",
"nuclide-commons": "0.5.0"
}
}

@@ -1,17 +0,18 @@

'use babel';
/* @flow */
/*
* Copyright (c) 2015-present, Facebook, Inc.
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
const fs = require('fs');
const path = require('path');
const invariant = require('assert');
const temp = require('temp').track();
const WatchmanClient = require('../lib/WatchmanClient');
import fs from 'fs';
import nuclideUri from 'nuclide-commons/nuclideUri';
import watchman from 'fb-watchman';
import WatchmanClient from '../lib/WatchmanClient';
import {generateFixture} from 'nuclide-commons/test-helpers';

@@ -21,6 +22,4 @@ const FILE_MODE = 33188;

describe('WatchmanClient test suite', () => {
let dirPath: string = '';
let client: any;
let filePath: string = '';
let client: WatchmanClient = (null: any);

@@ -30,11 +29,21 @@ beforeEach(() => {

client = new WatchmanClient();
dirPath = temp.mkdirSync();
filePath = path.join(dirPath, 'test.txt');
fs.writeFileSync(filePath, 'abc');
// Many people use restrict_root_files so watchman only will watch folders
// that have those listed files in them. This list of root files almost
// always has .git in it.
const watchmanRootPath = path.join(dirPath, '.git');
fs.mkdirSync(watchmanRootPath);
waits(1010);
waitsForPromise(async () => {
dirPath = await generateFixture(
'watchman_helpers_test',
new Map([
// Many people use restrict_root_files so watchman only will watch folders
// that have those listed files in them. watchmanconfig is always a root
// file.
['.watchmanconfig', '{}'],
['test.txt', 'abc'],
['non-used-file.txt', 'def'],
['nested/nested-test.txt', 'ghi'],
]),
);
// TODO(hansonw): This is a big change in Watchman behavior- figure out what
// this means for Nuclide's use.
dirPath = fs.realpathSync(dirPath);
waits(1010);
});
});

@@ -47,5 +56,13 @@

describe('restore subscriptions', () => {
it('restores subscriptions on client end', () => {
waitsForPromise(async () => {
const watcher = await client.watchDirectoryRecursive(dirPath);
function testRestoreSubscriptions(
onRestoreChange: (watchmanClient: watchman.Client) => void,
) {
// First watchman init can be slow and flaky.
waitsForPromise({timeout: 15000}, async () => {
const filePath = nuclideUri.join(dirPath, 'test.txt');
const watcher = await client
.watchDirectoryRecursive(dirPath)
// Give it two retries.
.catch(() => client.watchDirectoryRecursive(dirPath))
.catch(() => client.watchDirectoryRecursive(dirPath));
const changeHandler = jasmine.createSpy();

@@ -58,8 +75,17 @@ watcher.on('change', changeHandler);

expect(changeHandler.callCount).toBe(1);
expect(changeHandler.argsForCall[0][0]).toEqual([{name: 'test.txt', mode: FILE_MODE, new: false, exists: true}]);
// End the socket client to watchman to trigger restore subscriptions.
expect(changeHandler.argsForCall[0][0]).toEqual([
{
name: 'test.txt',
mode: FILE_MODE,
new: false,
exists: true,
},
]);
const internalClient = await client._clientPromise;
onRestoreChange(internalClient);
internalClient.end();
});
waits(1000); // Wait for WatchmanClient to restore subscriptions.
waits(1000); // Wait for watchman to watch the directory.
runs(() => advanceClock(3000)); // Pass the settle filesystem time.
waits(1000); // Wait for the client to restore subscriptions.
runs(() => fs.unlinkSync(filePath));

@@ -69,3 +95,10 @@ waitsFor(() => changeHandler.callCount > 1);

expect(changeHandler.callCount).toBe(2);
expect(changeHandler.argsForCall[1][0]).toEqual([{name: 'test.txt', mode: FILE_MODE, new: false, exists: false}]);
expect(changeHandler.argsForCall[1][0]).toEqual([
{
name: 'test.txt',
mode: FILE_MODE,
new: false,
exists: false,
},
]);
});

@@ -75,7 +108,45 @@ });

waitsForPromise(() => client.unwatch(dirPath));
}
it('restores subscriptions on client end', () => {
testRestoreSubscriptions(watchmanClient => {
// End the socket client to watchman to trigger restore subscriptions.
watchmanClient.end();
});
});
it('restores subscriptions on client error', () => {
testRestoreSubscriptions(watchmanClient => {
// End the socket client to watchman to trigger restore subscriptions.
watchmanClient.emit('error', new Error('fake error'));
});
});
/**
* This simulates the case where:
* 1. watchman fails, and then
* 2. the reconnection fails on startup
* 3. subsequent reconnections can still succeed.
*
* We need to make sure we don't end up in a deadlock where the first reconnection
* attempt blocks subsequent ones.
*/
it('restores subscriptions on client startup failure', () => {
testRestoreSubscriptions(watchmanClient => {
let counter = 0;
const oldConnect = watchman.Client.prototype.connect;
spyOn(watchman.Client.prototype, 'connect').andCallFake(function() {
if (counter++ === 0) {
this.emit('error', new Error('startup error'));
} else {
oldConnect.apply(this);
}
});
watchmanClient.emit('error', new Error('fake error'));
});
});
});
describe('cleanup watchers after unwatch', () => {
it('unwatch cleans up watchman watchlist resources', () => {
it('unwatch cleans up watchman subscriptions resources', () => {
waitsForPromise(async () => {

@@ -86,5 +157,9 @@ const dirRealPath = fs.realpathSync(dirPath);

expect(watchList.indexOf(dirRealPath)).not.toBe(-1);
// $FlowIssue
client.dispose = () => {};
await client.unwatch(dirPath);
const afterCleanupWatchList = await client._watchList();
expect(afterCleanupWatchList.indexOf(dirRealPath)).toBe(-1);
expect(client.hasSubscription(dirPath)).toBeFalsy();
// Didn't remove it from the watched directories.
const noWatchListCleanup = await client._watchList();
expect(noWatchListCleanup.indexOf(dirRealPath)).not.toBe(-1);
});

@@ -94,11 +169,2 @@ });

describe('version()', () => {
it('We need version 3.1.0 or bigger', () => {
waitsForPromise(async () => {
const version = await client.version();
expect(version > '3.0.999').toBe(true);
});
});
});
describe('watchProject()', () => {

@@ -108,29 +174,12 @@ it('should be able to watch nested project folders, but cleanup watchRoot', () => {

const dirRealPath = fs.realpathSync(dirPath);
// The .watchmanconfig file, amonst others that could also be configured
// define the project root directory.
fs.writeFileSync(path.join(dirPath, '.watchmanconfig'), '');
const nestedDirPath = path.join(dirPath, 'nested');
fs.mkdirSync(nestedDirPath);
const {watch: watchRoot, relative_path: relativePath} = await client._watchProject(nestedDirPath);
const nestedDirPath = nuclideUri.join(dirPath, 'nested');
const {
watch: watchRoot,
relative_path: relativePath,
} = await client._watchProject(nestedDirPath);
expect(watchRoot).toBe(dirRealPath);
expect(relativePath).toBe('nested');
await client._deleteWatcher(watchRoot);
});
});
it('fails with meaningful error when the version is < 3.1.0', () => {
client._watchmanVersionPromise = Promise.resolve('1.0.0');
waitsForPromise(async () => {
let watchVersionError;
try {
await client._watchProject(dirPath)
} catch (error) {
watchVersionError = error;
}
expect(watchVersionError).toBeDefined();
invariant(watchVersionError);
expect(watchVersionError.message).toMatch(/^Watchman version/);
});
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc