@@ -12,11 +12,11 @@ import type {HasteImpl, WorkerMessage, WorkerMetadata} from './types';
1212import path from 'path' ;
1313import * as docblock from 'jest-docblock' ;
1414import fs from 'graceful-fs' ;
15+ import blacklist from './blacklist' ;
1516import H from './constants' ;
1617import extractRequires from './lib/extract_requires' ;
1718
18- const JSON_EXTENSION = '.json' ;
19- const PACKAGE_JSON = path . sep + 'package' + JSON_EXTENSION ;
19+ const PACKAGE_JSON = path . sep + 'package.json' ;
2020
2121let hasteImpl : ?HasteImpl = null ;
2222let hasteImplModulePath : ?string = null ;
@@ -35,26 +35,33 @@ export async function worker(data: WorkerMessage): Promise<WorkerMetadata> {
3535 }
3636
3737 const filePath = data . filePath ;
38- const content = fs . readFileSync ( filePath , 'utf8' ) ;
3938 let module ;
4039 let id : ?string ;
4140 let dependencies ;
4241
4342 if ( filePath . endsWith ( PACKAGE_JSON ) ) {
44- const fileData = JSON . parse ( content ) ;
43+ const fileData = JSON . parse ( fs . readFileSync ( filePath , 'utf8' ) ) ;
44+
4545 if ( fileData . name ) {
4646 id = fileData . name ;
4747 module = [ filePath , H . PACKAGE ] ;
4848 }
49- } else if ( ! filePath . endsWith ( JSON_EXTENSION ) ) {
49+
50+ return { dependencies, id, module} ;
51+ }
52+
53+ if ( ! blacklist . has ( filePath . substr ( filePath . lastIndexOf ( '.' ) ) ) ) {
54+ const content = fs . readFileSync ( filePath , 'utf8' ) ;
55+
5056 if ( hasteImpl ) {
5157 id = hasteImpl . getHasteName ( filePath ) ;
5258 } else {
5359 const doc = docblock . parse ( docblock . extract ( content ) ) ;
54- const idPragmas = [ ] . concat ( doc . providesModule || doc . provides ) ;
55- id = idPragmas [ 0 ] ;
60+ id = [ ] . concat ( doc . providesModule || doc . provides ) [ 0 ] ;
5661 }
62+
5763 dependencies = extractRequires ( content ) ;
64+
5865 if ( id ) {
5966 module = [ filePath , H . MODULE ] ;
6067 }
0 commit comments