From aa9c67f306754f0ee916c9a2741684390a9adfb8 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 2 Jun 2017 10:33:07 -0700 Subject: [PATCH] Prevent babelrc package import failure on relative current path --- 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 edb9e0c76ebb..32210dba761b 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);