metro-file-map 0.76.6 → 0.76.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/flow-types.js.flow +2 -2
- package/src/index.js +7 -4
- package/src/index.js.flow +7 -4
- package/src/lib/TreeFS.js +0 -4
- package/src/lib/TreeFS.js.flow +0 -4
- package/src/watchers/NodeWatcher.js +6 -2
- package/src/watchers/NodeWatcher.js.flow +6 -2
- package/src/watchers/WatchmanWatcher.js +2 -1
- package/src/watchers/WatchmanWatcher.js.flow +2 -1
package/package.json
CHANGED
package/src/flow-types.js.flow
CHANGED
|
@@ -146,7 +146,7 @@ export type FileData = Map<Path, FileMetaData>;
|
|
|
146
146
|
|
|
147
147
|
export type FileMetaData = [
|
|
148
148
|
/* id */ string,
|
|
149
|
-
/* mtime */ number,
|
|
149
|
+
/* mtime */ ?number,
|
|
150
150
|
/* size */ number,
|
|
151
151
|
/* visited */ 0 | 1,
|
|
152
152
|
/* dependencies */ string,
|
|
@@ -156,7 +156,7 @@ export type FileMetaData = [
|
|
|
156
156
|
|
|
157
157
|
export type FileStats = $ReadOnly<{
|
|
158
158
|
fileType: 'f' | 'l',
|
|
159
|
-
modifiedTime: number,
|
|
159
|
+
modifiedTime: ?number,
|
|
160
160
|
}>;
|
|
161
161
|
|
|
162
162
|
export interface FileSystem {
|
package/src/index.js
CHANGED
|
@@ -867,11 +867,14 @@ class HasteMap extends _events.default {
|
|
|
867
867
|
const relativeFilePath = fastPath.relative(rootDir, absoluteFilePath);
|
|
868
868
|
const linkStats = fileSystem.linkStats(relativeFilePath);
|
|
869
869
|
|
|
870
|
-
// The file has been accessed, not modified
|
|
870
|
+
// The file has been accessed, not modified. If the modified time is
|
|
871
|
+
// null, then it is assumed that the watcher does not have capabilities
|
|
872
|
+
// to detect modified time, and change processing proceeds.
|
|
871
873
|
if (
|
|
872
874
|
type === "change" &&
|
|
873
875
|
linkStats != null &&
|
|
874
876
|
metadata &&
|
|
877
|
+
metadata.modifiedTime != null &&
|
|
875
878
|
linkStats.modifiedTime === metadata.modifiedTime
|
|
876
879
|
) {
|
|
877
880
|
return;
|
|
@@ -891,6 +894,8 @@ class HasteMap extends _events.default {
|
|
|
891
894
|
((!event.metadata && !metadata) ||
|
|
892
895
|
(event.metadata &&
|
|
893
896
|
metadata &&
|
|
897
|
+
event.metadata.modifiedTime != null &&
|
|
898
|
+
metadata.modifiedTime != null &&
|
|
894
899
|
event.metadata.modifiedTime === metadata.modifiedTime))
|
|
895
900
|
)
|
|
896
901
|
) {
|
|
@@ -915,9 +920,7 @@ class HasteMap extends _events.default {
|
|
|
915
920
|
// parse it and update the haste map.
|
|
916
921
|
if (type === "add" || type === "change") {
|
|
917
922
|
(0, _invariant.default)(
|
|
918
|
-
metadata != null &&
|
|
919
|
-
metadata.modifiedTime != null &&
|
|
920
|
-
metadata.size != null,
|
|
923
|
+
metadata != null && metadata.size != null,
|
|
921
924
|
"since the file exists or changed, it should have metadata"
|
|
922
925
|
);
|
|
923
926
|
const fileMetadata = [
|
package/src/index.js.flow
CHANGED
|
@@ -962,11 +962,14 @@ export default class HasteMap extends EventEmitter {
|
|
|
962
962
|
const relativeFilePath = fastPath.relative(rootDir, absoluteFilePath);
|
|
963
963
|
const linkStats = fileSystem.linkStats(relativeFilePath);
|
|
964
964
|
|
|
965
|
-
// The file has been accessed, not modified
|
|
965
|
+
// The file has been accessed, not modified. If the modified time is
|
|
966
|
+
// null, then it is assumed that the watcher does not have capabilities
|
|
967
|
+
// to detect modified time, and change processing proceeds.
|
|
966
968
|
if (
|
|
967
969
|
type === 'change' &&
|
|
968
970
|
linkStats != null &&
|
|
969
971
|
metadata &&
|
|
972
|
+
metadata.modifiedTime != null &&
|
|
970
973
|
linkStats.modifiedTime === metadata.modifiedTime
|
|
971
974
|
) {
|
|
972
975
|
return;
|
|
@@ -987,6 +990,8 @@ export default class HasteMap extends EventEmitter {
|
|
|
987
990
|
((!event.metadata && !metadata) ||
|
|
988
991
|
(event.metadata &&
|
|
989
992
|
metadata &&
|
|
993
|
+
event.metadata.modifiedTime != null &&
|
|
994
|
+
metadata.modifiedTime != null &&
|
|
990
995
|
event.metadata.modifiedTime === metadata.modifiedTime)),
|
|
991
996
|
)
|
|
992
997
|
) {
|
|
@@ -1013,9 +1018,7 @@ export default class HasteMap extends EventEmitter {
|
|
|
1013
1018
|
// parse it and update the haste map.
|
|
1014
1019
|
if (type === 'add' || type === 'change') {
|
|
1015
1020
|
invariant(
|
|
1016
|
-
metadata != null &&
|
|
1017
|
-
metadata.modifiedTime != null &&
|
|
1018
|
-
metadata.size != null,
|
|
1021
|
+
metadata != null && metadata.size != null,
|
|
1019
1022
|
'since the file exists or changed, it should have metadata',
|
|
1020
1023
|
);
|
|
1021
1024
|
const fileMetadata: FileMetaData = [
|
package/src/lib/TreeFS.js
CHANGED
|
@@ -122,10 +122,6 @@ class TreeFS {
|
|
|
122
122
|
}
|
|
123
123
|
const fileType = fileMetadata[_constants.default.SYMLINK] === 0 ? "f" : "l";
|
|
124
124
|
const modifiedTime = fileMetadata[_constants.default.MTIME];
|
|
125
|
-
(0, _invariant.default)(
|
|
126
|
-
typeof modifiedTime === "number",
|
|
127
|
-
"File in TreeFS missing modified time"
|
|
128
|
-
);
|
|
129
125
|
return {
|
|
130
126
|
fileType,
|
|
131
127
|
modifiedTime,
|
package/src/lib/TreeFS.js.flow
CHANGED
|
@@ -98,10 +98,6 @@ export default class TreeFS implements MutableFileSystem {
|
|
|
98
98
|
}
|
|
99
99
|
const fileType = fileMetadata[H.SYMLINK] === 0 ? 'f' : 'l';
|
|
100
100
|
const modifiedTime = fileMetadata[H.MTIME];
|
|
101
|
-
invariant(
|
|
102
|
-
typeof modifiedTime === 'number',
|
|
103
|
-
'File in TreeFS missing modified time',
|
|
104
|
-
);
|
|
105
101
|
return {
|
|
106
102
|
fileType,
|
|
107
103
|
modifiedTime,
|
|
@@ -310,7 +310,7 @@ module.exports = class NodeWatcher extends EventEmitter {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
} catch (error) {
|
|
313
|
-
if (error
|
|
313
|
+
if (!isIgnorableFileError(error)) {
|
|
314
314
|
this.emit("error", error);
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
@@ -368,7 +368,11 @@ module.exports = class NodeWatcher extends EventEmitter {
|
|
|
368
368
|
function isIgnorableFileError(error) {
|
|
369
369
|
return (
|
|
370
370
|
error.code === "ENOENT" ||
|
|
371
|
-
// Workaround Windows EPERM on watched folder deletion
|
|
371
|
+
// Workaround Windows EPERM on watched folder deletion, and when
|
|
372
|
+
// reading locked files (pending further writes or pending deletion).
|
|
373
|
+
// In such cases, we'll receive a subsequent event when the file is
|
|
374
|
+
// deleted or ready to read.
|
|
375
|
+
// https://github.com/facebook/metro/issues/1001
|
|
372
376
|
// https://github.com/nodejs/node-v0.x-archive/issues/4337
|
|
373
377
|
(error.code === "EPERM" && platform === "win32")
|
|
374
378
|
);
|
|
@@ -340,7 +340,7 @@ module.exports = class NodeWatcher extends EventEmitter {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
} catch (error) {
|
|
343
|
-
if (error
|
|
343
|
+
if (!isIgnorableFileError(error)) {
|
|
344
344
|
this.emit('error', error);
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
@@ -403,7 +403,11 @@ module.exports = class NodeWatcher extends EventEmitter {
|
|
|
403
403
|
function isIgnorableFileError(error: Error | {code: string}) {
|
|
404
404
|
return (
|
|
405
405
|
error.code === 'ENOENT' ||
|
|
406
|
-
// Workaround Windows EPERM on watched folder deletion
|
|
406
|
+
// Workaround Windows EPERM on watched folder deletion, and when
|
|
407
|
+
// reading locked files (pending further writes or pending deletion).
|
|
408
|
+
// In such cases, we'll receive a subsequent event when the file is
|
|
409
|
+
// deleted or ready to read.
|
|
410
|
+
// https://github.com/facebook/metro/issues/1001
|
|
407
411
|
// https://github.com/nodejs/node-v0.x-archive/issues/4337
|
|
408
412
|
(error.code === 'EPERM' && platform === 'win32')
|
|
409
413
|
);
|
|
@@ -286,8 +286,9 @@ class WatchmanWatcher extends _events.default {
|
|
|
286
286
|
// Change event on dirs are mostly useless.
|
|
287
287
|
!(type === "d" && eventType === CHANGE_EVENT)
|
|
288
288
|
) {
|
|
289
|
+
const mtime = Number(mtime_ms);
|
|
289
290
|
self._emitEvent(eventType, relativePath, self.root, {
|
|
290
|
-
modifiedTime:
|
|
291
|
+
modifiedTime: mtime !== 0 ? mtime : null,
|
|
291
292
|
size,
|
|
292
293
|
type,
|
|
293
294
|
});
|
|
@@ -289,8 +289,9 @@ export default class WatchmanWatcher extends EventEmitter {
|
|
|
289
289
|
// Change event on dirs are mostly useless.
|
|
290
290
|
!(type === 'd' && eventType === CHANGE_EVENT)
|
|
291
291
|
) {
|
|
292
|
+
const mtime = Number(mtime_ms);
|
|
292
293
|
self._emitEvent(eventType, relativePath, self.root, {
|
|
293
|
-
modifiedTime:
|
|
294
|
+
modifiedTime: mtime !== 0 ? mtime : null,
|
|
294
295
|
size,
|
|
295
296
|
type,
|
|
296
297
|
});
|