Skip to content

Commit

Permalink
chore: cleanup ws dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 1, 2023
1 parent 4b946ca commit b8dc99b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
15 changes: 6 additions & 9 deletions packages/vitest/src/node/state.ts
@@ -1,15 +1,11 @@
import { relative } from 'pathe'
import type { File, Task, TaskResultPack, UserConsoleLog } from '../types'
import type { File, Task, TaskResultPack } from '@vitest/runner'

// can't import actual functions from utils, because it's incompatible with @vitest/browsers
import type { AggregateError as AggregateErrorPonyfill } from '../utils'
import type { AggregateError as AggregateErrorPonyfill } from '../utils/base'
import type { UserConsoleLog } from '../types/general'
import type { WorkspaceProject } from './workspace'

interface CollectingPromise {
promise: Promise<void>
resolve: () => void
}

export function isAggregateError(err: unknown): err is AggregateErrorPonyfill {
if (typeof AggregateError !== 'undefined' && err instanceof AggregateError)
return true
Expand All @@ -21,7 +17,6 @@ export function isAggregateError(err: unknown): err is AggregateErrorPonyfill {
export class StateManager {
filesMap = new Map<string, File[]>()
pathsSet: Set<string> = new Set()
collectingPromise: CollectingPromise | undefined = undefined
browserTestPromises = new Map<string, { resolve: (v: unknown) => void; reject: (v: unknown) => void }>()
idMap = new Map<string, Task>()
taskFileMap = new WeakMap<Task, File>()
Expand Down Expand Up @@ -92,7 +87,9 @@ export class StateManager {
})
}

clearFiles(project: WorkspaceProject, paths: string[] = []) {
// this file is reused by ws-client, and shoult not rely on heavy dependencies like workspace
clearFiles(_project: { config: { name: string } }, paths: string[] = []) {
const project = _project as WorkspaceProject
paths.forEach((path) => {
const files = this.filesMap.get(path)
if (!files)
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/utils/base.ts
@@ -1,4 +1,4 @@
import type { Arrayable, Nullable } from '../types'
import type { Arrayable, Nullable } from '../types/general'

export { notNullish, getCallLastIndex } from '@vitest/utils'

Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/utils/tasks.ts
@@ -1,5 +1,6 @@
import { getNames, getTests } from '@vitest/runner/utils'
import type { Arrayable, Suite, Task } from '../types'
import type { Suite, Task } from '@vitest/runner'
import type { Arrayable } from '../types/general'
import { toArray } from './base'

export { getTasks, getTests, getSuites, hasTests, hasFailed, getNames } from '@vitest/runner/utils'
Expand Down

0 comments on commit b8dc99b

Please sign in to comment.