From 35c2743898e723f908085696f3fdde7492591e9c Mon Sep 17 00:00:00 2001 From: cpojer Date: Tue, 13 Jun 2017 19:26:19 +0100 Subject: [PATCH] Hard-fail if hasteImpl is throwing an error during initialization. --- packages/jest-haste-map/src/worker.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/jest-haste-map/src/worker.js b/packages/jest-haste-map/src/worker.js index e35bb9db6f12..2edda75ce216 100644 --- a/packages/jest-haste-map/src/worker.js +++ b/packages/jest-haste-map/src/worker.js @@ -40,20 +40,20 @@ const formatError = (error: string | Error): SerializableError => { }; module.exports = (data: WorkerMessage, callback: WorkerCallback): void => { - try { - if ( - data.hasteImplModulePath && - data.hasteImplModulePath !== hasteImplModulePath - ) { - if (hasteImpl) { - throw new Error('jest-haste-map: hasteImplModulePath changed'); - } - hasteImplModulePath = data.hasteImplModulePath; - hasteImpl = - // $FlowFixMe: dynamic require - (require(hasteImplModulePath): HasteImpl); + if ( + data.hasteImplModulePath && + data.hasteImplModulePath !== hasteImplModulePath + ) { + if (hasteImpl) { + throw new Error('jest-haste-map: hasteImplModulePath changed'); } + hasteImplModulePath = data.hasteImplModulePath; + hasteImpl = + // $FlowFixMe: dynamic require + (require(hasteImplModulePath): HasteImpl); + } + try { const filePath = data.filePath; const content = fs.readFileSync(filePath, 'utf8'); let module;