From 95aacbe3bdeae1e41bb52b2f7708471907e95092 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Tue, 6 Jun 2017 02:35:17 -0700 Subject: [PATCH] Prevent babelrc package import failure on relative current path (#3723) --- packages/babel-jest/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index 0ef7b3fe7050..4a5b295f151d 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -47,7 +47,10 @@ const createTransformer = (options: any) => { cache[directory] = JSON.stringify(require(configJsFilePath)); break; } - const packageJsonFilePath = path.join(directory, PACKAGE_JSON); + const resolvedJsonFilePath = path.join(directory, PACKAGE_JSON); + const packageJsonFilePath = resolvedJsonFilePath === PACKAGE_JSON + ? path.resolve(directory, PACKAGE_JSON) + : resolvedJsonFilePath; if (fs.existsSync(packageJsonFilePath)) { // $FlowFixMe const packageJsonFileContents = require(packageJsonFilePath);