Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[haste-map]: Ignore Sapling vcs directories #13674

Merged
merged 2 commits into from Jan 1, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

### Features

- `[jest-haste-map]` ignore Sapling vcs directories (`.sl/`) ([#13674](https://github.com/facebook/jest/pull/13674))
- `[jest-resolve]` Support subpath imports ([#13705](https://github.com/facebook/jest/pull/13705))
- `[jest-runtime]` Add `jest.isolateModulesAsync` for scoped module initialization of asynchronous functions ([#13680](https://github.com/facebook/jest/pull/13680))
- `[jest-test-result]` Added `skipped` and `focused` status to `FormattedTestResult` ([#13700](https://github.com/facebook/jest/pull/13700))
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Expand Up @@ -2270,7 +2270,7 @@ An array of RegExp patterns that are matched against all source file paths befor

These patterns match against the full path. Use the `<rootDir>` string token to include the path to your project's root directory to prevent it from accidentally ignoring all of your files in different environments that may have different root directories. Example: `["<rootDir>/node_modules/"]`.

Even if nothing is specified here, the watcher will ignore changes to the version control folders (.git, .hg). Other hidden files and directories, i.e. those that begin with a dot (`.`), are watched by default. Remember to escape the dot when you add them to `watchPathIgnorePatterns` as it is a special RegExp character.
Even if nothing is specified here, the watcher will ignore changes to the version control folders (.git, .hg, .sl). Other hidden files and directories, i.e. those that begin with a dot (`.`), are watched by default. Remember to escape the dot when you add them to `watchPathIgnorePatterns` as it is a special RegExp character.

```js tab
/** @type {import('jest').Config} */
Expand Down
8 changes: 8 additions & 0 deletions packages/jest-haste-map/src/__tests__/index.test.js
Expand Up @@ -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([]);
Comment on lines +353 to +354
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the patch in index.ts this throws an error about "could not parse invalid JSON"

});

it('ignores vcs directories with ignore pattern regex', async () => {
const config = {...defaultConfig, ignorePattern: /Kiwi/};
mockFs[path.join('/', 'project', 'fruits', 'Kiwi.js')] = `
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-haste-map/src/index.ts
Expand Up @@ -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('|');

Expand Down