Skip to content

Commit

Permalink
feat: add "skipHastePackages" option
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Feb 1, 2019
1 parent 2780a77 commit 953661d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/jest-haste-map/src/index.js
Expand Up @@ -67,6 +67,7 @@ type Options = {
retainAllFiles: boolean,
rootDir: string,
roots: Array<string>,
skipHastePackages?: boolean,
throwOnModuleCollision?: boolean,
useWatchman?: boolean,
watch?: boolean,
Expand All @@ -90,6 +91,7 @@ type InternalOptions = {
retainAllFiles: boolean,
rootDir: string,
roots: Array<string>,
skipHastePackages: boolean,
throwOnModuleCollision: boolean,
useWatchman: boolean,
watch: boolean,
Expand All @@ -108,6 +110,7 @@ export type FS = HasteFS;
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 canUseWatchman = ((): boolean => {
try {
Expand Down Expand Up @@ -251,6 +254,7 @@ class HasteMap extends EventEmitter {
retainAllFiles: options.retainAllFiles,
rootDir: options.rootDir,
roots: Array.from(new Set(options.roots)),
skipHastePackages: !!options.skipHastePackages,
throwOnModuleCollision: !!options.throwOnModuleCollision,
useWatchman: options.useWatchman == null ? true : options.useWatchman,
watch: !!options.watch,
Expand Down Expand Up @@ -620,6 +624,12 @@ class HasteMap extends EventEmitter {
}

for (const relativeFilePath of hasteMap.files.keys()) {
if (
this._options.skipHastePackages &&
relativeFilePath.endsWith(PACKAGE_JSON)
) {
continue;
}
// SHA-1, if requested, should already be present thanks to the crawler.
const filePath = fastPath.resolve(
this._options.rootDir,
Expand Down

0 comments on commit 953661d

Please sign in to comment.