Skip to content

Commit

Permalink
chore: Fixed xo warning on collectFlowCoverageForFile parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rpl committed Jul 8, 2018
1 parent 84ef534 commit 4a23f86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/__tests__/test-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ it(
const filename = 'src/fakeFilename.js';

const collectData = await flow.collectFlowCoverageForFile(
'flow', '/fake/projectDir/', filename, tmpDirPath
{flowCommandPath: 'flow', projectDir: '/fake/projectDir/'}, filename, tmpDirPath
);

// Expect a flow coverage exception in the collected data.
Expand Down Expand Up @@ -214,7 +214,7 @@ it('collectFlowCoverageForFile collects parsing errors', async () => {
const filename = 'src/fakeFilename.js';

const collectData = await flow.collectFlowCoverageForFile(
'flow', '/fake/projectDir/', filename, tmpDirPath
{flowCommandPath: 'flow', projectDir: '/fake/projectDir/'}, filename, tmpDirPath
);

let expectedParsingError;
Expand Down Expand Up @@ -262,7 +262,7 @@ it('collectFlowCoverageForFile collects coverage errors', async () => {
const filename = 'src/fakeFilename.js';

const collectData = await flow.collectFlowCoverageForFile(
'flow', '/fake/projectDir/', filename, tmpDirPath
{flowCommandPath: 'flow', projectDir: '/fake/projectDir/'}, filename, tmpDirPath
);

// Expect a flow coverage exception in the collected data.
Expand Down Expand Up @@ -316,7 +316,7 @@ it('collectFlowCoverageForFile resolve coverage data', async () => {
const flow = require(LIB_FLOW);

const res = await flow.collectFlowCoverageForFile(
'flow', DEFAULT_FLOW_TIMEOUT, '/fake/projectDir', filename
{flowCommandPath: 'flow', flowCommandTimeout: DEFAULT_FLOW_TIMEOUT, projectDir: '/fake/projectDir'}, filename
);

expect(mockWriteFile.mock.calls.length).toBe(0);
Expand Down
20 changes: 14 additions & 6 deletions src/lib/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,25 @@ export type FlowCoverageJSONData = {
flowCoverageStderr?: string|Buffer
}

export async function collectFlowCoverageForFile(
type CollectFlowCoverageForFileOptions = {
flowCommandPath: string,
flowCommandTimeout: number,
projectDir: string,
strictCoverage: bool,
};

export async function collectFlowCoverageForFile(
opts: CollectFlowCoverageForFileOptions,
filename: string,
tmpDirPath: ?string,
strictCoverage: ?boolean,
): Promise<FlowCoverageJSONData> {
const {
flowCommandPath,
flowCommandTimeout,
projectDir,
strictCoverage
} = opts;

let tmpFilePath: ?string;

if (process.env.VERBOSE && process.env.VERBOSE === 'DUMP_JSON') {
Expand Down Expand Up @@ -372,7 +383,6 @@ export function collectFlowCoverage(
): Promise<FlowCoverageSummaryData> {
const {
flowCommandPath,
flowCommandTimeout,
projectDir,
globIncludePatterns,
globExcludePatterns = [],
Expand Down Expand Up @@ -456,9 +466,7 @@ export function collectFlowCoverage(
console.log(`Queue ${filename} flow coverage data collection`);
}

waitForCollectedDataFromFiles.push(collectFlowCoverageForFile(
flowCommandPath, flowCommandTimeout, projectDir, filename, tmpDirPath, strictCoverage
).then(data => {
waitForCollectedDataFromFiles.push(collectFlowCoverageForFile(opts, filename, tmpDirPath).then(data => {
/* eslint-disable camelcase */
coverageSummaryData.covered_count += data.expressions.covered_count;
coverageSummaryData.uncovered_count += data.expressions.uncovered_count;
Expand Down

0 comments on commit 4a23f86

Please sign in to comment.