Skip to content

Commit

Permalink
fix: the cli option is passed to coverage.exclude (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Jun 6, 2023
1 parent 50f0700 commit c37cdeb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/vitest/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { normalize } from 'pathe'
import cac from 'cac'
import c from 'picocolors'
import { version } from '../../package.json'
import type { Vitest, VitestRunMode } from '../types'
import { toArray } from '../utils'
import type { BaseCoverageOptions, CoverageC8Options, CoverageIstanbulOptions, Vitest, VitestRunMode } from '../types'
import type { CliOptions } from './cli-api'
import { startVitest } from './cli-api'
import { divider } from './reporters/renderers/utils'
Expand Down Expand Up @@ -147,6 +148,20 @@ function normalizeCliOptions(argv: CliOptions): CliOptions {
else
delete argv.dir

if (argv.coverage) {
const coverage = argv.coverage
if (coverage.exclude)
coverage.exclude = toArray(coverage.exclude)

if ((coverage as BaseCoverageOptions).include)
(coverage as BaseCoverageOptions).include = toArray((coverage as BaseCoverageOptions).include)

if ((coverage as CoverageIstanbulOptions).ignoreClassMethods)
(coverage as CoverageIstanbulOptions).ignoreClassMethods = toArray((coverage as CoverageIstanbulOptions).ignoreClassMethods)

if ((coverage as CoverageC8Options).src)
(coverage as CoverageC8Options).src = toArray((coverage as CoverageC8Options).src)
}
return argv
}

Expand Down

0 comments on commit c37cdeb

Please sign in to comment.