Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions packages/metro-file-map/src/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion packages/metro-file-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading