diff --git a/package.json b/package.json index 24b8f8cc..223759ab 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "find-up": "4.1.0", "glob": "7.1.6", "inquirer": "7.0.3", + "jest-worker": "^24.9.0", "lodash.merge": "4.6.2", "micromatch": "4.0.2", "ora": "4.0.3", diff --git a/src/commands/install-types.js b/src/commands/install-types.js index ff059284..19300362 100644 --- a/src/commands/install-types.js +++ b/src/commands/install-types.js @@ -1,12 +1,14 @@ // @flow -const exec = require('./../lib/exec.js'); +const {default: Workder} = require('jest-worker'); + const path = require('./../lib/paths.js'); const dependency = require('./../lib/dependency.js'); const flowTyped = require('./../lib/flowTyped.js'); const {info, success, error} = require('./../lib/logger.js'); async function installFlowTypes() { + const exec = new Workder(require.resolve('./../lib/exec.js')); const [rootPath, packagePaths] = await Promise.all([ path.resolveMonoRepoRootPath(), path.resolveMonoRepoPackagePaths() @@ -41,6 +43,7 @@ async function installFlowTypes() { ); success('Installed "flow-typed" definitions'); + exec.end(); } module.exports = installFlowTypes; diff --git a/src/commands/install-types.spec.js b/src/commands/install-types.spec.js index d3f86ada..f437fe18 100644 --- a/src/commands/install-types.spec.js +++ b/src/commands/install-types.spec.js @@ -1,5 +1,7 @@ // @flow +jest.mock('jest-worker'); + jest.mock('./../lib/paths.js'); jest.mock('./../lib/logger.js'); jest.mock('./../lib/dependency.js'); @@ -7,6 +9,8 @@ jest.mock('./../lib/flowTyped.js'); jest.mock('./../lib/exec.js'); console.error = jest.fn(); +const {default: Worker} = require('jest-worker'); + const path: any = require('./../lib/paths.js'); const dependency: any = require('./../lib/dependency.js'); const flowTyped: any = require('./../lib/flowTyped.js'); @@ -16,6 +20,13 @@ const exec: any = require('./../lib/exec.js'); const installFlowTypes = require('./install-types.js'); describe('install-types', () => { + beforeAll(() => { + Worker.mockImplementation(() => ({ + asyncWithRetries: exec.asyncWithRetries, + end: () => {} + })); + }); + afterEach(() => { // $FlowFixMe: Ignore errors since the jest type-def is out of date. jest.restoreAllMocks();