Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add/change -> touch #1414

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[ignore]
<PROJECT_ROOT>/packages/.*/build/.*
<PROJECT_ROOT>/\.hg/.*
# this transient dep bundles tests with their package, which flow attempts to parse
# and crashes out as the test includes purposely malformed json
<PROJECT_ROOT>\(/.*\)?/node_modules/resolve/test/.*
Expand Down
49 changes: 17 additions & 32 deletions packages/metro-file-map/src/Watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
*/

import type {
ChangeEventMetadata,
Console,
CrawlerOptions,
FileData,
Path,
PerfLogger,
WatcherBackendChangeEvent,
WatchmanClocks,
} from './flow-types';
import type {WatcherOptions as WatcherBackendOptions} from './watchers/common';
import type {AbortSignal} from 'node-abort-controller';

import nodeCrawl from './crawlers/node';
import watchmanCrawl from './crawlers/watchman';
import {ADD_EVENT, CHANGE_EVENT} from './watchers/common';
import {TOUCH_EVENT} from './watchers/common';
import FSEventsWatcher from './watchers/FSEventsWatcher';
import NodeWatcher from './watchers/NodeWatcher';
import WatchmanWatcher from './watchers/WatchmanWatcher';
Expand Down Expand Up @@ -163,14 +163,7 @@ export class Watcher extends EventEmitter {
}
}

async watch(
onChange: (
type: string,
filePath: string,
root: string,
metadata: ChangeEventMetadata,
) => void,
) {
async watch(onChange: (change: WatcherBackendChangeEvent) => void) {
const {extensions, ignorePattern, useWatchman} = this._options;

// WatchmanWatcher > FSEventsWatcher > sane.NodeWatcher
Expand Down Expand Up @@ -214,29 +207,21 @@ export class Watcher extends EventEmitter {

watcher.once('ready', () => {
clearTimeout(rejectTimeout);
watcher.on(
'all',
(
type: string,
filePath: string,
root: string,
metadata: ChangeEventMetadata,
) => {
const basename = path.basename(filePath);
if (basename.startsWith(this._options.healthCheckFilePrefix)) {
if (type === ADD_EVENT || type === CHANGE_EVENT) {
debug(
'Observed possible health check cookie: %s in %s',
filePath,
root,
);
this._handleHealthCheckObservation(basename);
}
return;
watcher.on('all', (change: WatcherBackendChangeEvent) => {
const basename = path.basename(change.relativePath);
if (basename.startsWith(this._options.healthCheckFilePrefix)) {
if (change.event === TOUCH_EVENT) {
debug(
'Observed possible health check cookie: %s in %s',
change.relativePath,
root,
);
this._handleHealthCheckObservation(basename);
}
onChange(type, filePath, root, metadata);
},
);
return;
}
onChange(change);
});
resolve(watcher);
});
});
Expand Down
Loading
Loading