Skip to content

Commit

Permalink
refactor: replace os.cpus with os.availableParallelism (#4639)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Dec 4, 2023
1 parent 43008fe commit f35e2c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ Watermarks for statements, lines, branches and functions. See [istanbul document
#### coverage.processingConcurrency

- **Type:** `boolean`
- **Default:** `Math.min(20, os.cpus().length)`
- **Default:** `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
- **Available for providers:** `'v8' | 'istanbul'`
- **CLI:** `--coverage.processingConcurrency=<number>`

Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cpus } from 'node:os'
import os from 'node:os'
import type { BenchmarkUserOptions, CoverageV8Options, ResolvedCoverageOptions, UserConfig } from './types'
import { isCI } from './utils/env'

Expand Down Expand Up @@ -43,7 +43,7 @@ export const coverageConfigDefaults: ResolvedCoverageOptions = {
reporter: [['text', {}], ['html', {}], ['clover', {}], ['json', {}]],
extension: ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte', '.marko'],
allowExternal: false,
processingConcurrency: Math.min(20, cpus().length),
processingConcurrency: Math.min(20, os.availableParallelism?.() ?? os.cpus().length),
}

export const fakeTimersDefaults = {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/types/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export interface BaseCoverageOptions {

/**
* Concurrency limit used when processing the coverage results.
* Defaults to `Math.min(20, os.cpus().length)`
* Defaults to `Math.min(20, os.availableParallelism?.() ?? os.cpus().length)`
*/
processingConcurrency?: number
}
Expand Down

0 comments on commit f35e2c7

Please sign in to comment.