Skip to content

Commit

Permalink
Hard-fail if hasteImpl is throwing an error during initialization. (j…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer authored Jun 13, 2017
1 parent 1cf3771 commit ee7ed57
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/jest-haste-map/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee7ed57

Please sign in to comment.