td> 8 年 前 css-overflow-anchor.json 11e3a9652a first 8 年 前 css-overscroll-behavior.json 11e3a9652a first 8 年 前 css-page-break.json 11e3a9652a first 8 年 前 css-paged-media.json 11e3a9652a first 8 年 前 css-paint-api.json 11e3a9652a first 8 年 前 css-placeholder-shown.json 11e3a9652a first 8 年 前 css-placeholder.json 11e3a9652a first 8 年 前 css-read-only-write.json 11e3a9652a first 8 年 前 css-rebeccapurple.json 11e3a9652a first 8 年 前 css-reflections.json 11e3a9652a first 8 年 前 css-regions.json 11e3a9652a first 8 年 前 css-repeating-gradients.json 11e3a9652a first 8 年 前 css-resize.json 11e3a9652a first 8 年 前 css-revert-value.json 11e3a9652a first 8 年 前 css-rrggbbaa.json 11e3a9652a first 8 年 前 css-scroll-behavior.json 11e3a9652a first 8 年 前 css-scrollbar.json 11e3a9652a first 8 年 前 css-sel2.json 11e3a9652a first 8 年 前 css-sel3.json 11e3a9652a first 8 年 前 css-selection.json 11e3a9652a first 8 年 前 css-shapes.json 11e3a9652a first 8 年 前 css-snappoints.json 11e3a9652a first 8 年 前 css-sticky.json 11e3a9652a first 8 年 前 css-supports-api.json 11e3a9652a first 8 年 前 css-table.json 11e3a9652a first 8 年 前 css-text-align-last.json 11e3a9652a first 8 年 前 css-text-indent.json 11e3a9652a first 8 年 前 css-text-justify.json 11e3a9652a first 8 年 前 css-text-orientation.json 11e3a9652a first 8 年 前 css-text-spacing.json 11e3a9652a first 8 年 前 css-textshadow.json 11e3a9652a first 8 年 前 css-touch-action-2.json 11e3a9652a first 8 年 前 css-touch-action.json 11e3a9652a first 8 年 前 css-transitions.json 11e3a9652a first 8 年 前 css-unicode-bidi.json 11e3a9652a first 8 年 前 css-unset-value.json 11e3a9652a first 8 年 前 css-variables.json 11e3a9652a first 8 年 前 css-widows-orphans.json 11e3a9652a first 8 年 前 css-writing-mode.json 11e3a9652a first 8 年 前 css-zoom.json 11e3a9652a first 8 年 前 css3-attr.json 11e3a9652a first 8 年 前 css3-boxsizing.json 11e3a9652a first 8 年 前 css3-colors.json 11e3a9652a first 8 年 前 css3-cursors-grab.json 11e3a9652a first 8 年 前 css3-cursors-newer.json 11e3a9652a first 8 年 前 css3-cursors.json 11e3a9652a first 8 年 前 css3-tabsize.json 11e3a9652a first 8 年 前 currentcolor.json 11e3a9652a first 8 年 前 custom-elements.json 11e3a9652a first 8 年 前 custom-elementsv1.json 11e3a9652a first 8 年 前 customevent.json 11e3a9652a first 8 年 前 datalist.json 11e3a9652a first 8 年 前 dataset.json 11e3a9652a first 8 年 前 datauri.json 11e3a9652a first 8 年 前 details.json 11e3a9652a first 8 年 前 deviceorientation.json 11e3a9652a first 8 年 前 devicepixelratio.json 11e3a9652a first 8 年 前 dialog.json 11e3a9652a first 8 年 前 dispatchevent.json 11e3a9652a first 8 年 前 do-not-track.json 11e3a9652a first 8 年 前 document-currentscript.json 11e3a9652a first 8 年 前 document-evaluate-xpath.json 11e3a9652a first 8 年 前 document-execcommand.json 11e3a9652a first 8 年 前 document-scrollingelement.json 11e3a9652a first 8 年 前 documenthead.json 11e3a9652a first 8 年 前 dom-manip-convenience.json 11e3a9652a first 8 年 前 dom-range.json 11e3a9652a first 8 年 前 domcontentloaded.json 11e3a9652a first 8 年 前 domfocusin-domfocusout-events.json 11e3a9652a first 8 年 前 dommatrix.json 11e3a9652a first 8 年 前 download.json 11e3a9652a first 8 年 前 dragndrop.json 11e3a9652a first 8 年 前 element-closest.json 11e3a9652a first 8 年 前 element-from-point.json 11e3a9652a first 8 年 前 eme.json 11e3a9652a first 8 年 前 eot.json 11e3a9652a first 8 年 前 es5.json 11e3a9652a first 8 年 前 es6-class.json 11e3a9652a first 8 年 前 es6-generators.json 11e3a9652a first 8 年 前 es6-module-dynamic-import.json 11e3a9652a first 8 年 前 es6-module.json 11e3a9652a first 8 年 前 es6-number.json 11e3a9652a first 8 年 前 es6-string-includes.json 11e3a9652a first 8 年 前 eventsource.json 11e3a9652a first 8 年 前 fetch.json 11e3a9652a first 8 年 前 fieldset-disabled.json 11e3a9652a first 8 年 前 fileapi.json 11e3a9652a first 8 年 前 filereader.json 11e3a9652a first 8 年 前 filereadersync.json 11e3a9652a first 8 年 前 filesystem.json 11e3a9652a first 8 年 前 flac.json 11e3a9652a first 8 年 前 flexbox.json 11e3a9652a first 8 年 前 flow-root.json 11e3a9652a first 8 年 前 focusin-focusout-events.json 11e3a9652a first 8 年 前 focusoptions-preventscroll.json 11e3a9652a first 8 年 前 font-family-system-ui.json 11e3a9652a first 8 年 前 font-feature.json 11e3a9652a first 8 年 前 font-kerning.json 11e3a9652a first 8 年 前 font-loading.json 11e3a9652a first 8 年 前 font-size-adjust.json 11e3a9652a first 8 年 前 font-smooth.json 11e3a9652a first 8 年 前 font-unicode-range.json 11e3a9652a first 8 年 前 font-variant-alternates.json 11e3a9652a first 8 年 前 font-variant-east-asian.json 11e3a9652a first 8 年 前 fontface.json 11e3a9652a first 8 年 前 form-attribute.json 11e3a9652a first 8 年 前 form-submit-attributes.json 11e3a9652a first 8 年 前 form-validation.json 11e3a9652a first 8 年 前 forms.json 11e3a9652a first 8 年 前 fullscreen.json 11e3a9652a first 8 年 前 gamepad.json 11e3a9652a first 8 年 前 geolocation.json 11e3a9652a first 8 年 前 getboundingclientrect.json 11e3a9652a first 8 年 前 getcomputedstyle.json 11e3a9652a first 8 年 前 getelementsbyclassname.json 11e3a9652a first 8 年 前 getrandomvalues.json 11e3a9652a first 8 年 前 hardwareconcurrency.json 11e3a9652a first 8 年 前 hashchange.json 11e3a9652a first 8 年 前 heif.json 11e3a9652a first 8 年 前 hevc.json 11e3a9652a first 8 年 前 hidden.json 11e3a9652a first 8 年 前 high-resolution-time.json 11e3a9652a first 8 年 前 history.json 11e3a9652a first 8 年 前 html-media-capture.json 11e3a9652a first 8 年 前 html5semantic.json 11e3a9652a first 8 年 前 http-live-streaming.json 11e3a9652a first 8 年 前 http2.json 11e3a9652a first 8 年 前 iframe-sandbox.json 11e3a9652a first 8 年 前 iframe-seamless.json 11e3a9652a first 8 年 前 iframe-srcdoc.json 11e3a9652a first 8 年 前 imagecapture.json 11e3a9652a first 8 年 前 ime.json 11e3a9652a first 8 年 前 img-naturalwidth-naturalheight.json 11e3a9652a first 8 年 前 imports.json 11e3a9652a first 8 年 前 indeterminate-checkbox.json 11e3a9652a first 8 年 前 indexeddb.json 11e3a9652a first 8 年 前 indexeddb2.json 11e3a9652a first 8 年 前 inline-block.json 11e3a9652a first 8 年 前 innertext.json 11e3a9652a first 8 年 前 input-autocomplete-onoff.json 11e3a9652a first 8 年 前 input-color.json 11e3a9652a first 8 年 前 input-datetime.json 11e3a9652a first 8 年 前 input-email-tel-url.json 11e3a9652a first 8 年 前 input-event.json 11e3a9652a first 8 年 前 input-file-accept.json 11e3a9652a first 8 年 前 input-file-directory.json 11e3a9652a first 8 年 前 input-file-multiple.json 11e3a9652a first 8 年 前 input-inputmode.json 11e3a9652a first 8 年 前 input-minlength.json 11e3a9652a first 8 年 前 input-number.json 11e3a9652a first 8 年 前 input-pattern.json 11e3a9652a first 8 年 前 input-placeholder.json 11e3a9652a first 8 年 前 input-range.json 11e3a9652a first 8 年 前 input-search.json 11e3a9652a first 8 年 前 input-selection.json 11e3a9652a first 8 年 前 insert-adjacent.json 11e3a9652a first 8 年 前 insertadjacenthtml.json 11e3a9652a first 8 年 前 internationalization.json 11e3a9652a first 8 年 前 intersectionobserver.json 11e3a9652a first 8 年 前 intrinsic-width.json 11e3a9652a first 8 年 前 jpeg2000.json 11e3a9652a first 8 年 前 jpegxr.json 11e3a9652a first 8 年 前 json.json 11e3a9652a first 8 年 前 kerning-pairs-ligatures.json 11e3a9652a first 8 年 前 keyboardevent-charcode.json 11e3a9652a first 8 年 前 keyboardevent-code.json 11e3a9652a first 8 年 前 keyboardevent-getmodifierstate.json 11e3a9652a first 8 年 前 keyboardevent-key.json 11e3a9652a first 8 年 前 keyboardevent-location.json 11e3a9652a first 8 年 前 keyboardevent-which.json 11e3a9652a first 8 年 前 lazyload.json 11e3a9652a first 8 年 前 let.json 11e3a9652a first 8 年 前 link-icon-png.json 11e3a9652a first 8 年 前 link-icon-svg.json 11e3a9652a first 8 年 前 link-rel-dns-prefetch.json 11e3a9652a first 8 年 前 link-rel-preconnect.json 11e3a9652a first 8 年 前 link-rel-prefetch.json 11e3a9652a first 8 年 前 link-rel-preload.json 11e3a9652a first 8 年 前 link-rel-prerender.json 11e3a9652a first 8 年 前 localecompare.json 11e3a9652a first 8 年 前 matchesselector.json 11e3a9652a first 8 年 前 matchmedia.json 11e3a9652a first 8 年 前 mathml.json 11e3a9652a first 8 年 前 maxlength.json 11e3a9652a first 8 年 前 media-attribute.json 11e3a9652a first 8 年 前 media-fragments.json 11e3a9652a first 8 年 前 media-session-api.json 11e3a9652a first 8 年 前 mediacapture-fromelement.json 11e3a9652a first 8 年 前 mediarecorder.json 11e3a9652a first 8 年 前 mediasource.json 11e3a9652a first 8 年 前 menu.json 11e3a9652a first 8 年 前 meter.json 11e3a9652a first 8 年 前 midi.json 11e3a9652a first 8 年 前 minmaxwh.json 11e3a9652a first 8 年 前 mp3.json 11e3a9652a first 8 年 前 mpeg-dash.json 11e3a9652a first 8 年 前 mpeg4.json 11e3a9652a first 8 年 前 multibackgrounds.json 11e3a9652a first 8 年 前 multicolumn.json 11e3a9652a first 8 年 前 mutation-events.json 11e3a9652a first 8 年 前 mutationobserver.json 11e3a9652a first 8 年 前 namevalue-storage.json 11e3a9652a first 8 年 前 nav-timing.json 11e3a9652a first 8 年 前 navigator-language.json 11e3a9652a first 8 年 前 netinfo.json 11e3a9652a first 8 年 前 node-contains.json 11e3a9652a first 8 年 前 node-parentelement.json 11e3a9652a first 8 年 前 notifications.json 11e3a9652a first 8 年 前 object-fit.json 11e3a9652a first 8 年 前 object-observe.json 11e3a9652a first 8 年 前 object-values.json 11e3a9652a first 8 年 前 objectrtc.json 11e3a9652a first 8 年 前 offline-apps.json 11e3a9652a first 8 年 前 offscreencanvas.json 11e3a9652a first 8 年 前 ogg-vorbis.json 11e3a9652a first 8 年 前 ogv.json 11e3a9652a first 8 年 前 ol-reversed.json 11e3a9652a first 8 年 前 once-event-listener.json 11e3a9652a first 8 年 前 online-status.json 11e3a9652a first 8 年 前 opus.json 11e3a9652a first 8 年 前 outline.json 11e3a9652a first 8 年 前 pad-start-end.json 11e3a9652a first 8 年 前 page-transition-events.json 11e3a9652a first 8 年 前 pagevisibility.json 11e3a9652a first 8 年 前 passive-event-listener.json 11e3a9652a first 8 年 前 path2d.json 11e3a9652a first 8 年 前 payment-request.json 11e3a9652a first 8 年 前 permissions-api.json 11e3a9652a first 8 年 前 picture.json 11e3a9652a first 8 年 前 ping.json 11e3a9652a first 8 年 前 png-alpha.json 11e3a9652a first 8 年 前 pointer-events.json 11e3a9652a first 8 年 前 pointer.json 11e3a9652a first 8 年 前 pointerlock.json 11e3a9652a first 8 年 前 prefers-reduced-motion.json 11e3a9652a first 8 年 前 progress.json 11e3a9652a first 8 年 前 promises.json 11e3a9652a first 8 年 前 proximity.json 11e3a9652a first 8 年 前 proxy.json 11e3a9652a first 8 年 前 publickeypinning.json 11e3a9652a first 8 年 前 push-api.json 11e3a9652a first 8 年 前 queryselector.json 11e3a9652a first 8 年 前 readonly-attr.json 11e3a9652a first 8 年 前 referrer-policy.json 11e3a9652a first 8 年 前 registerprotocolhandler.json 11e3a9652a first 8 年 前 rel-noopener.json 11e3a9652a first 8 年 前 rel-noreferrer.json 11e3a9652a first 8 年 前 rellist.json 11e3a9652a first 8 年 前 rem.json 11e3a9652a first 8 年 前 requestanimationframe.json 11e3a9652a first 8 年 前 requestidlecallback.json 11e3a9652a first 8 年 前 resizeobserver.json 11e3a9652a first 8 年 前 resource-timing.json 11e3a9652a first 8 年 前 rest-parameters.json 11e3a9652a first 8 年 前 rtcpeerconnection.json 11e3a9652a first 8 年 前 ruby.json 11e3a9652a first 8 年 前 run-in.json 11e3a9652a first 8 年 前 same-site-cookie-attribute.json 11e3a9652a first 8 年 前 screen-orientation.json 11e3a9652a first 8 年 前 script-async.json 11e3a9652a first 8 年 前 script-defer.json 11e3a9652a first 8 年 前 scrollintoview.json 11e3a9652a first 8 年 前 scrollintoviewifneeded.json 11e3a9652a first 8 年 前 sdch.json 11e3a9652a first 8 年 前 selection-api.json 11e3a9652a first 8 年 前 server-timing.json 11e3a9652a first 8 年 前 serviceworkers.json 11e3a9652a first 8 年 前 setimmediate.json 11e3a9652a first 8 年 前 sha-2.json 11e3a9652a first 8 年 前 shadowdom.json 11e3a9652a first 8 年 前 shadowdomv1.json 11e3a9652a first 8 年 前 sharedworkers.json 11e3a9652a first 8 年 前 sni.json 11e3a9652a first 8 年 前 spdy.json 11e3a9652a first 8 年 前 speech-recognition.json 11e3a9652a first 8 年 前 speech-synthesis.json 11e3a9652a first 8 年 前 spellcheck-attribute.json 11e3a9652a first 8 年 前 sql-storage.json 11e3a9652a first 8 年 前 srcset.json 11e3a9652a first 8 年 前 stopimmediatepropagation.json 11e3a9652a first 8 年 前 stream.json 11e3a9652a first 8 年 前 streams.json 11e3a9652a first 8 年 前 stricttransportsecurity.json 11e3a9652a first 8 年 前 style-scoped.json 11e3a9652a first 8 年 前 subresource-integrity.json 11e3a9652a first 8 年 前 svg-css.json 11e3a9652a first 8 年 前 svg-filters.json 11e3a9652a first 8 年 前 svg-fonts.json 11e3a9652a first 8 年 前 svg-fragment.json 11e3a9652a first 8 年 前 svg-html.json 11e3a9652a first 8 年 前 svg-html5.json 11e3a9652a first 8 年 前 svg-img.json 11e3a9652a first 8 年 前 svg-smil.json 11e3a9652a first 8 年 前 svg.json 11e3a9652a first 8 年 前 symbols.json 11e3a9652a first 8 年 前 tabindex-attr.json 11e3a9652a first 8 年 前 template-literals.json 11e3a9652a first 8 年 前 template.json 11e3a9652a first 8 年 前 testfeat.json 11e3a9652a first 8 年 前 text-decoration.json 11e3a9652a first 8 年 前 text-emphasis.json 11e3a9652a first 8 年 前 text-overflow.json 11e3a9652a first 8 年 前 text-size-adjust.json 11e3a9652a first 8 年 前 text-stroke.json 11e3a9652a first 8 年 前 textcontent.json 11e3a9652a first 8 年 前 textencoder.json 11e3a9652a first 8 年 前 tls1-1.json 11e3a9652a first 8 年 前 tls1-2.json 11e3a9652a first 8 年 前 tls1-3.json 11e3a9652a first 8 年 前 token-binding.json 11e3a9652a first 8 年 前 touch.json 11e3a9652a first 8 年 前 transforms2d.json 11e3a9652a first 8 年 前 transforms3d.json 11e3a9652a first 8 年 前 ttf.json 11e3a9652a first 8 年 前 typedarrays.json 11e3a9652a first 8 年 前 u2f.json 11e3a9652a first 8 年 前 unhandledrejection.json 11e3a9652a first 8 年 前 upgradeinsecurerequests.json 11e3a9652a first 8 年 前 url.json 11e3a9652a first 8 年 前 urlsearchparams.json 11e3a9652a first 8 年 前 use-strict.json 11e3a9652a first 8 年 前 user-select-none.json 11e3a9652a first 8 年 前 user-timing.json 11e3a9652a first 8 年 前 variable-fonts.json 11e3a9652a first 8 年 前 vibration.json 11e3a9652a first 8 年 前 video.json 11e3a9652a first 8 年 前 videotracks.json 11e3a9652a first 8 年 前 viewport-units.json 11e3a9652a first 8 年 前 wai-aria.json 11e3a9652a first 8 年 前 wasm.json 11e3a9652a first 8 年 前 wav.json 11e3a9652a first 8 年 前 wbr-element.json 11e3a9652a first 8 年 前 web-animation.json 11e3a9652a first 8 年 前 web-app-manifest.json 11e3a9652a first 8 年 前 web-bluetooth.json 11e3a9652a first 8 年 前 web-share.json 11e3a9652a first 8 年 前 webgl.json 11e3a9652a first 8 年 前 webgl2.json 11e3a9652a first 8 年 前 webm.json 11e3a9652a first 8 年 前 webp.json 11e3a9652a first 8 年 前 websockets.json 11e3a9652a first 8 年 前 webusb.json 11e3a9652a first 8 年 前 webvr.json 11e3a9652a first 8 年 前 webvtt.json 11e3a9652a first 8 年 前 webworkers.json 11e3a9652a first 8 年 前 will-change.json 11e3a9652a first 8 年 前 woff.json 11e3a9652a first 8 年 前 woff2.json 11e3a9652a first 8 年 前 word-break.json 11e3a9652a first 8 年 前 wordwrap.json 11e3a9652a first 8 年 前 x-doc-messaging.json 11e3a9652a first 8 年 前 x-frame-options.json 11e3a9652a first 8 年 前 xhr2.json 11e3a9652a first 8 年 前 xhtml.json 11e3a9652a first 8 年 前 xhtmlsmil.json 11e3a9652a first 8 年 前 xml-serializer.json 11e3a9652a first 8 年 前 adminSystem - Gogs: Go Git Service

Нет описания

watchman_watcher.js 8.5KB

    'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = WatchmanWatcher; var _fs; function _load_fs() { return _fs = _interopRequireDefault(require('fs')); } var _path; function _load_path() { return _path = _interopRequireDefault(require('path')); } var _assert; function _load_assert() { return _assert = _interopRequireDefault(require('assert')); } var _common; function _load_common() { return _common = _interopRequireDefault(require('sane/src/common')); } var _fbWatchman; function _load_fbWatchman() { return _fbWatchman = _interopRequireDefault(require('fb-watchman')); } var _events; function _load_events() { return _events = require('events'); } var _recrawlWarningDedupe; function _load_recrawlWarningDedupe() { return _recrawlWarningDedupe = _interopRequireDefault(require('sane/src/utils/recrawl-warning-dedupe')); } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const CHANGE_EVENT = (_common || _load_common()).default.CHANGE_EVENT; /** * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ const DELETE_EVENT = (_common || _load_common()).default.DELETE_EVENT; const ADD_EVENT = (_common || _load_common()).default.ADD_EVENT; const ALL_EVENT = (_common || _load_common()).default.ALL_EVENT; const SUB_NAME = 'sane-sub'; /** * Watches `dir`. * * @class PollWatcher * @param String dir * @param {Object} opts * @public */ function WatchmanWatcher(dir, opts) { (_common || _load_common()).default.assignOptions(this, opts); this.root = (_path || _load_path()).default.resolve(dir); this.init(); } // eslint-disable-next-line no-proto WatchmanWatcher.prototype.__proto__ = (_events || _load_events()).EventEmitter.prototype; /** * Run the watchman `watch` command on the root and subscribe to changes. * * @private */ WatchmanWatcher.prototype.init = function () { if (this.client) { this.client.removeAllListeners(); } const self = this; this.client = new (_fbWatchman || _load_fbWatchman()).default.Client(); this.client.on('error', error => { self.emit('error', error); }); this.client.on('subscription', this.handleChangeEvent.bind(this)); this.client.on('end', () => { console.warn('[sane] Warning: Lost connection to watchman, reconnecting..'); self.init(); }); this.watchProjectInfo = null; function getWatchRoot() { return self.watchProjectInfo ? self.watchProjectInfo.root : self.root; } function onCapability(error, resp) { if (handleError(self, error)) { // The Watchman watcher is unusable on this system, we cannot continue return; } handleWarning(resp); self.capabilities = resp.capabilities; if (self.capabilities.relative_root) { self.client.command(['watch-project', getWatchRoot()], onWatchProject); } else { self.client.command(['watch', getWatchRoot()], onWatch); } } function onWatchProject(error, resp) { if (handleError(self, error)) { return; } handleWarning(resp); self.watchProjectInfo = { relativePath: resp.relative_path ? resp.relative_path : '', root: resp.watch }; self.client.command(['clock', getWatchRoot()], onClock); } function onWatch(error, resp) { if (handleError(self, error)) { return; } handleWarning(resp); self.client.command(['clock', getWatchRoot()], onClock); } function onClock(error, resp) { if (handleError(self, error)) { return; } handleWarning(resp); const options = { fields: ['name', 'exists', 'new'], since: resp.clock }; // If the server has the wildmatch capability available it supports // the recursive **/*.foo style match and we can offload our globs // to the watchman server. This saves both on data size to be // communicated back to us and compute for evaluating the globs // in our node process. if (self.capabilities.wildmatch) { if (self.globs.length === 0) { if (!self.dot) { // Make sure we honor the dot option if even we're not using globs. options.expression = ['match', '**', 'wholename', { includedotfiles: false }]; } } else { options.expression = ['anyof']; for (const i in self.globs) { options.expression.push(['match', self.globs[i], 'wholename', { includedotfiles: self.dot }]); } } } if (self.capabilities.relative_root) { options.relative_root = self.watchProjectInfo.relativePath; } self.client.command(['subscribe', getWatchRoot(), SUB_NAME, options], onSubscribe); } function onSubscribe(error, resp) { if (handleError(self, error)) { return; } handleWarning(resp); self.emit('ready'); } self.client.capabilityCheck({ optional: ['wildmatch', 'relative_root'] }, onCapability); }; /** * Handles a change event coming from the subscription. * * @param {Object} resp * @private */ WatchmanWatcher.prototype.handleChangeEvent = function (resp) { (_assert || _load_assert()).default.equal(resp.subscription, SUB_NAME, 'Invalid subscription event.'); if (resp.is_fresh_instance) { this.emit('fresh_instance'); } if (resp.is_fresh_instance) { this.emit('fresh_instance'); } if (Array.isArray(resp.files)) { resp.files.forEach(this.handleFileChange, this); } }; /** * Handles a single change event record. * * @param {Object} changeDescriptor * @private */ WatchmanWatcher.prototype.handleFileChange = function (changeDescriptor) { const self = this; let absPath; let relativePath; if (this.capabilities.relative_root) { relativePath = changeDescriptor.name; absPath = (_path || _load_path()).default.join(this.watchProjectInfo.root, this.watchProjectInfo.relativePath, relativePath); } else { absPath = (_path || _load_path()).default.join(this.root, changeDescriptor.name); relativePath = changeDescriptor.name; } if (!(self.capabilities.wildmatch && !this.hasIgnore) && !(_common || _load_common()).default.isFileIncluded(this.globs, this.dot, this.doIgnore, relativePath)) { return; } if (!changeDescriptor.exists) { self.emitEvent(DELETE_EVENT, relativePath, self.root); } else { (_fs || _load_fs()).default.lstat(absPath, (error, stat) => { // Files can be deleted between the event and the lstat call // the most reliable thing to do here is to ignore the event. if (error && error.code === 'ENOENT') { return; } if (handleError(self, error)) { return; } const eventType = changeDescriptor.new ? ADD_EVENT : CHANGE_EVENT; // Change event on dirs are mostly useless. if (!(eventType === CHANGE_EVENT && stat.isDirectory())) { self.emitEvent(eventType, relativePath, self.root, stat); } }); } }; /** * Dispatches the event. * * @param {string} eventType * @param {string} filepath * @param {string} root * @param {fs.Stat} stat * @private */ WatchmanWatcher.prototype.emitEvent = function (eventType, filepath, root, stat) { this.emit(eventType, filepath, root, stat); this.emit(ALL_EVENT, eventType, filepath, root, stat); }; /** * Closes the watcher. * * @param {function} callback * @private */ WatchmanWatcher.prototype.close = function (callback) { this.client.removeAllListeners(); this.client.end(); callback && callback(null, true); }; /** * Handles an error and returns true if exists. * * @param {WatchmanWatcher} self * @param {Error} error * @private */ function handleError(self, error) { if (error != null) { self.emit('error', error); return true; } else { return false; } } /** * Handles a warning in the watchman resp object. * * @param {object} resp * @private */ function handleWarning(resp) { if ('warning' in resp) { if ((_recrawlWarningDedupe || _load_recrawlWarningDedupe()).default.isRecrawlWarningDupe(resp.warning)) { return true; } console.warn(resp.warning); return true; } else { return false; } }