55 * LICENSE file in the root directory of this source tree.
66 */
77
8- import { execSync } from 'child_process' ;
9- import { createHash } from 'crypto' ;
10- import { EventEmitter } from 'events' ;
8+ import { execSync } from 'child_process' ;
9+ import { createHash } from 'crypto' ;
10+ import { EventEmitter } from 'events' ;
1111import * as fs from 'fs' ;
12- import { tmpdir } from 'os' ;
12+ import { tmpdir } from 'os' ;
1313import * as path from 'path' ;
14- import { NodeWatcher , Watcher as SaneWatcher } from 'sane' ;
15- import { Config } from '@jest/types' ;
14+ import { NodeWatcher , Watcher as SaneWatcher } from 'sane' ;
15+ import { Config } from '@jest/types' ;
1616import serializer from 'jest-serializer' ;
1717import Worker from 'jest-worker' ;
18- import { getSha1 , worker } from './worker' ;
18+ import { getSha1 , worker } from './worker' ;
1919import getMockName from './getMockName' ;
2020import getPlatformExtension from './lib/getPlatformExtension' ;
2121import H from './constants' ;
@@ -39,7 +39,6 @@ import {
3939 HasteRegExp ,
4040 InternalHasteMap ,
4141 HasteMap as InternalHasteMapObject ,
42- Mapper ,
4342 MockData ,
4443 ModuleMapData ,
4544 ModuleMetaData ,
@@ -58,7 +57,6 @@ type Options = {
5857 forceNodeFilesystemAPI ?: boolean ;
5958 hasteImplModulePath ?: string ;
6059 ignorePattern ?: HasteRegExp ;
61- mapper ?: Mapper ;
6260 maxWorkers : number ;
6361 mocksPattern ?: string ;
6462 name : string ;
@@ -83,7 +81,6 @@ type InternalOptions = {
8381 forceNodeFilesystemAPI : boolean ;
8482 hasteImplModulePath ?: string ;
8583 ignorePattern ?: HasteRegExp ;
86- mapper ?: Mapper ;
8784 maxWorkers : number ;
8885 mocksPattern : RegExp | null ;
8986 name : string ;
@@ -102,7 +99,7 @@ type Watcher = {
10299 close ( callback : ( ) => void ) : void ;
103100} ;
104101
105- type WorkerInterface = { worker : typeof worker ; getSha1 : typeof getSha1 } ;
102+ type WorkerInterface = { worker : typeof worker ; getSha1 : typeof getSha1 } ;
106103
107104// TODO: Ditch namespace when this module exports ESM
108105namespace HasteMap {
@@ -120,13 +117,13 @@ const PACKAGE_JSON = path.sep + 'package.json';
120117
121118// TypeScript doesn't like us importing from outside `rootDir`, but it doesn't
122119// understand `require`.
123- const { version : VERSION } = require ( '../package.json' ) ;
120+ const { version : VERSION } = require ( '../package.json' ) ;
124121
125122const canUseWatchman = ( ( ) : boolean => {
126123 try {
127- execSync ( 'watchman --version' , { stdio : [ 'ignore' ] } ) ;
124+ execSync ( 'watchman --version' , { stdio : [ 'ignore' ] } ) ;
128125 return true ;
129- } catch ( e ) { }
126+ } catch ( e ) { }
130127 return false ;
131128} ) ( ) ;
132129
@@ -140,12 +137,12 @@ const getWhiteList = (list: Array<string> | undefined): RegExp | null => {
140137 ) ;
141138 return new RegExp (
142139 '(' +
143- escapePathSeparator ( NODE_MODULES ) +
144- '(?:' +
145- newList . join ( '|' ) +
146- ')(?=$|' +
147- escapePathSeparator ( path . sep ) +
148- '))' ,
140+ escapePathSeparator ( NODE_MODULES ) +
141+ '(?:' +
142+ newList . join ( '|' ) +
143+ ')(?=$|' +
144+ escapePathSeparator ( path . sep ) +
145+ '))' ,
149146 'g' ,
150147 ) ;
151148 }
@@ -261,7 +258,6 @@ class HasteMap extends EventEmitter {
261258 forceNodeFilesystemAPI : ! ! options . forceNodeFilesystemAPI ,
262259 hasteImplModulePath : options . hasteImplModulePath ,
263260 ignorePattern : options . ignorePattern ,
264- mapper : options . mapper ,
265261 maxWorkers : options . maxWorkers ,
266262 mocksPattern : options . mocksPattern
267263 ? new RegExp ( options . mocksPattern )
@@ -281,7 +277,7 @@ class HasteMap extends EventEmitter {
281277 if ( options . ignorePattern && ! ( options . ignorePattern instanceof RegExp ) ) {
282278 this . _console . warn (
283279 'jest-haste-map: the `ignorePattern` options as a function is being ' +
284- 'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.' ,
280+ 'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.' ,
285281 ) ;
286282 }
287283
@@ -437,7 +433,7 @@ class HasteMap extends EventEmitter {
437433 map : ModuleMapData ,
438434 mocks : MockData ,
439435 filePath : Config . Path ,
440- workerOptions ?: { forceInBand : boolean } ,
436+ workerOptions ?: { forceInBand : boolean } ,
441437 ) : Promise < void > | null {
442438 const rootDir = this . _options . rootDir ;
443439
@@ -651,7 +647,7 @@ class HasteMap extends EventEmitter {
651647 changedFiles ?: FileData ;
652648 hasteMap : InternalHasteMap ;
653649 } ) : Promise < InternalHasteMap > {
654- const { removedFiles, changedFiles, hasteMap} = data ;
650+ const { removedFiles, changedFiles, hasteMap } = data ;
655651
656652 // If any files were removed or we did not track what files changed, process
657653 // every file looking for changes. Otherwise, process only changed files.
@@ -727,10 +723,10 @@ class HasteMap extends EventEmitter {
727723 /**
728724 * Creates workers or parses files and extracts metadata in-process.
729725 */
730- private _getWorker ( options ?: { forceInBand : boolean } ) : WorkerInterface {
726+ private _getWorker ( options ?: { forceInBand : boolean } ) : WorkerInterface {
731727 if ( ! this . _worker ) {
732728 if ( ( options && options . forceInBand ) || this . _options . maxWorkers <= 1 ) {
733- this . _worker = { getSha1, worker} ;
729+ this . _worker = { getSha1, worker } ;
734730 } else {
735731 // @ts -ignore: assignment of a worker with custom properties.
736732 this . _worker = new Worker ( require . resolve ( './worker' ) , {
@@ -755,7 +751,6 @@ class HasteMap extends EventEmitter {
755751 extensions : options . extensions ,
756752 forceNodeFilesystemAPI : options . forceNodeFilesystemAPI ,
757753 ignore,
758- mapper : options . mapper ,
759754 rootDir : options . rootDir ,
760755 roots : options . roots ,
761756 } ;
@@ -764,18 +759,18 @@ class HasteMap extends EventEmitter {
764759 if ( crawl === watchmanCrawl ) {
765760 this . _console . warn (
766761 `jest-haste-map: Watchman crawl failed. Retrying once with node ` +
767- `crawler.\n` +
768- ` Usually this happens when watchman isn't running. Create an ` +
769- `empty \`.watchmanconfig\` file in your project's root folder or ` +
770- `initialize a git or hg repository in your project.\n` +
771- ` ` +
772- error ,
762+ `crawler.\n` +
763+ ` Usually this happens when watchman isn't running. Create an ` +
764+ `empty \`.watchmanconfig\` file in your project's root folder or ` +
765+ `initialize a git or hg repository in your project.\n` +
766+ ` ` +
767+ error ,
773768 ) ;
774769 return nodeCrawl ( crawlerOptions ) . catch ( e => {
775770 throw new Error (
776771 `Crawler retry failed:\n` +
777- ` Original error: ${ error . message } \n` +
778- ` Retry error: ${ e . message } \n` ,
772+ ` Original error: ${ error . message } \n` +
773+ ` Retry error: ${ e . message } \n` ,
779774 ) ;
780775 } ) ;
781776 }
@@ -808,8 +803,8 @@ class HasteMap extends EventEmitter {
808803 canUseWatchman && this . _options . useWatchman
809804 ? WatchmanWatcher
810805 : FSEventsWatcher . isSupported ( )
811- ? FSEventsWatcher
812- : NodeWatcher ;
806+ ? FSEventsWatcher
807+ : NodeWatcher ;
813808
814809 const extensions = this . _options . extensions ;
815810 const ignorePattern = this . _options . ignorePattern ;
@@ -907,7 +902,7 @@ class HasteMap extends EventEmitter {
907902 }
908903
909904 const add = ( ) => {
910- eventsQueue . push ( { filePath, stat, type} ) ;
905+ eventsQueue . push ( { filePath, stat, type } ) ;
911906 return null ;
912907 } ;
913908
@@ -967,7 +962,7 @@ class HasteMap extends EventEmitter {
967962 hasteMap . map ,
968963 hasteMap . mocks ,
969964 filePath ,
970- { forceInBand : true } ,
965+ { forceInBand : true } ,
971966 ) ;
972967 // Cleanup
973968 this . _cleanup ( ) ;
0 commit comments