mirror of https://github.com/status-im/metro.git
metro-memory-fs: Do not report a file change when reading a file
Reviewed By: jeanlauliac Differential Revision: D7584517 fbshipit-source-id: 55f87d15c723f697ea00c357da1d36f5d31accbb
This commit is contained in:
parent
bd5d776a2f
commit
d0fdca73cd
|
@ -429,6 +429,15 @@ describe('watch', () => {
|
|||
watcher.close();
|
||||
});
|
||||
|
||||
it('does not report changes when just reading a file', () => {
|
||||
const changedPaths = [];
|
||||
fs.writeFileSync('/foo.txt', '');
|
||||
const watcher = collectWatchEvents('/', {}, changedPaths);
|
||||
fs.readFileSync('/foo.txt');
|
||||
expect(changedPaths).toEqual([]);
|
||||
watcher.close();
|
||||
});
|
||||
|
||||
function collectWatchEvents(entPath, options, events) {
|
||||
return fs.watch(entPath, options, (eventName, filePath) => {
|
||||
events.push([eventName, filePath]);
|
||||
|
|
|
@ -197,7 +197,9 @@ class MemoryFs {
|
|||
|
||||
closeSync = (fd: number): void => {
|
||||
const desc = this._getDesc(fd);
|
||||
this._emitFileChange(desc.nodePath.slice(), {eventType: 'change'});
|
||||
if (desc.writable) {
|
||||
this._emitFileChange(desc.nodePath.slice(), {eventType: 'change'});
|
||||
}
|
||||
this._fds.delete(fd);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue