diff --git a/docs/Configuration.md b/docs/Configuration.md index 86955cf94c..33ea3a9184 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -1013,7 +1013,7 @@ Whether to periodically check the [filesystem watcher](./Concepts.md#file-watchi Type: `string` -The name of the temporary file that health checks write into the project. Defaults to `'.metro-health-check'`. +The name of the temporary file that health checks write into the project. Metro ignores files whose names start with this prefix. Defaults to `'.metro-health-check'`, which is also used if this is an empty string. :::note diff --git a/packages/metro-file-map/src/__tests__/index-test.js b/packages/metro-file-map/src/__tests__/index-test.js index 86ef936a27..41c6a18bb5 100644 --- a/packages/metro-file-map/src/__tests__/index-test.js +++ b/packages/metro-file-map/src/__tests__/index-test.js @@ -540,6 +540,18 @@ describe('FileMap', () => { expect([...fileSystem.matchFiles({filter: /Kiwi/})]).toEqual([]); }); + test('an empty health check file prefix does not exclude any files', async () => { + mockFs[p('/project/fruits/Kiwi.js')] = ` + // Kiwi! + `; + const {fileSystem} = await buildNewFileMap({ + healthCheck: {...defaultConfig.healthCheck, filePrefix: ''}, + }); + expect([...fileSystem.matchFiles({filter: /Kiwi/})]).toEqual([ + p('/project/fruits/Kiwi.js'), + ]); + }); + test('ignores vcs directories without ignore pattern', async () => { mockFs[p('/project/fruits/.git/fruit-history.js')] = ` // test diff --git a/packages/metro-file-map/src/index.js b/packages/metro-file-map/src/index.js index e66df92653..e0680ebd99 100644 --- a/packages/metro-file-map/src/index.js +++ b/packages/metro-file-map/src/index.js @@ -752,7 +752,11 @@ export default class FileMap extends EventEmitter { crawl: this.#crawler, enableSymlinks, extensions, - healthCheckFilePrefix: this.#options.healthCheck.filePrefix, + // Files whose names start with this prefix are health check files, which + // are left out of the crawl and the watcher's changes. Every name starts + // with an empty prefix, so the default is used instead. + healthCheckFilePrefix: + this.#options.healthCheck.filePrefix || '.metro-health-check', // TODO: Refactor out the two different ignore strategies here. ignoreForCrawl: filePath => { const ignoreMatched = ignorePattern.test(filePath);