From 98ee4fff5bce37150bc26687da955b05ca5de907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?= =?UTF-8?q?an?= Date: Tue, 13 Dec 2022 16:54:23 -0800 Subject: [PATCH] [haste-map]: Ignore Sapling vcs directories Summary: Ignore `.sl` directories in HasteMap. This will allow Sapling to be used with jest projects Test Plan: `packages/jest-haste-map/src/__tests__/index.test.js` similar testing plan to what's in #13673 Closes #13673 --- packages/jest-haste-map/src/__tests__/index.test.js | 8 ++++++++ packages/jest-haste-map/src/index.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index b93a752a096d..013de8971133 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -346,6 +346,14 @@ describe('HasteMap', () => { expect(hasteFS.matchFiles('.git')).toEqual([]); }); + it('ignores sapling vcs directories without ignore pattern', async () => { + mockFs[path.join('/', 'project', 'fruits', '.sl', 'package.json')] = ` + invalid}{ + `; + const {hasteFS} = await (await HasteMap.create(defaultConfig)).build(); + expect(hasteFS.matchFiles('.sl')).toEqual([]); + }); + it('ignores vcs directories with ignore pattern regex', async () => { const config = {...defaultConfig, ignorePattern: /Kiwi/}; mockFs[path.join('/', 'project', 'fruits', 'Kiwi.js')] = ` diff --git a/packages/jest-haste-map/src/index.ts b/packages/jest-haste-map/src/index.ts index 5c3458c96686..e4ddf1e1f856 100644 --- a/packages/jest-haste-map/src/index.ts +++ b/packages/jest-haste-map/src/index.ts @@ -125,7 +125,7 @@ const CHANGE_INTERVAL = 30; const MAX_WAIT_TIME = 240000; const NODE_MODULES = `${path.sep}node_modules${path.sep}`; const PACKAGE_JSON = `${path.sep}package.json`; -const VCS_DIRECTORIES = ['.git', '.hg'] +const VCS_DIRECTORIES = ['.git', '.hg', '.sl'] .map(vcs => escapePathForRegex(path.sep + vcs + path.sep)) .join('|');