Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
BUGFIX: Use jest-worker with install-types to fix ENOMEM (#311)
Browse files Browse the repository at this point in the history
* fix(install-types): use for to fix ENOMEM

* Revert "fix(install-types): use for to fix ENOMEM"

This reverts commit d4efe67.

* improvement(install-types): use jest-worker

* fix(commands): fix testing and lint error
  • Loading branch information
HsuTing authored and Roman Heckendorf committed Jan 13, 2020
1 parent 23542e1 commit 52ae34a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/commands/install-types.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -41,6 +43,7 @@ async function installFlowTypes() {
);

success('Installed "flow-typed" definitions');
exec.end();
}

module.exports = installFlowTypes;
11 changes: 11 additions & 0 deletions src/commands/install-types.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// @flow

jest.mock('jest-worker');

jest.mock('./../lib/paths.js');
jest.mock('./../lib/logger.js');
jest.mock('./../lib/dependency.js');
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');
Expand All @@ -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();
Expand Down

0 comments on commit 52ae34a

Please sign in to comment.