From 74a77190436d443161e8ee7c84a39efe6de65b92 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 25 Jan 2019 18:30:41 +0100 Subject: [PATCH] fix: break dependency cycle in jest-cli --- CHANGELOG.md | 2 ++ packages/jest-cli/src/cli/index.js | 3 +-- packages/jest-cli/src/jest.js | 5 ++--- packages/jest-cli/src/version.js | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 packages/jest-cli/src/version.js diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe5dd6e1e43..957ba423d82c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +- `[jest-cli]` Break dependency cycle when using Jest programmatically ([#7707](https://github.com/facebook/jest/pull/7707) + ### Chore & Maintenance - `[website]` Fix broken help link on homepage ([#7706](https://github.com/facebook/jest/pull/7706)) diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index 031c92d53446..a5d766fdd490 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -33,8 +33,7 @@ import rimraf from 'rimraf'; import {sync as realpath} from 'realpath-native'; import init from '../lib/init'; import logDebugMessages from '../lib/log_debug_messages'; - -const {getVersion} = require('../jest'); +import getVersion from '../version'; export async function run(maybeArgv?: Argv, project?: Path) { try { diff --git a/packages/jest-cli/src/jest.js b/packages/jest-cli/src/jest.js index 98011013820f..22210bef096e 100644 --- a/packages/jest-cli/src/jest.js +++ b/packages/jest-cli/src/jest.js @@ -7,18 +7,17 @@ * @flow */ -import {version as VERSION} from '../package.json'; - import SearchSource from './SearchSource'; import TestScheduler from './TestScheduler'; import TestWatcher from './TestWatcher'; import {run, runCLI} from './cli'; +import getVersion from './version'; module.exports = { SearchSource, TestScheduler, TestWatcher, - getVersion: () => VERSION, + getVersion, run, runCLI, }; diff --git a/packages/jest-cli/src/version.js b/packages/jest-cli/src/version.js new file mode 100644 index 000000000000..23a05d19add1 --- /dev/null +++ b/packages/jest-cli/src/version.js @@ -0,0 +1,14 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + */ + +import {version as VERSION} from '../package.json'; + +export default function getVersion() { + return VERSION; +}