Skip to content

Commit c31472d

Browse files
authored
refactor: mark internal isCached* methods (#7164)
1 parent 6a09cc3 commit c31472d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/browser/src/node/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
364364
name: 'vitest:browser:in-source-tests',
365365
transform(code, id) {
366366
const project = parentServer.vitest.getProjectByName(parentServer.config.name)
367-
if (!project.isCachedTestFile(id) || !code.includes('import.meta.vitest')) {
367+
if (!project._isCachedTestFile(id) || !code.includes('import.meta.vitest')) {
368368
return
369369
}
370370
const s = new MagicString(code, { filename: cleanUrl(id) })

packages/vitest/src/node/project.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,15 @@ export class TestProject {
394394
* Returns if the file is a test file. Requires `.globTestFiles()` to be called first.
395395
* @internal
396396
*/
397-
isCachedTestFile(testPath: string): boolean {
397+
_isCachedTestFile(testPath: string): boolean {
398398
return !!this.testFilesList && this.testFilesList.includes(testPath)
399399
}
400400

401401
/**
402402
* Returns if the file is a typecheck test file. Requires `.globTestFiles()` to be called first.
403403
* @internal
404404
*/
405-
isCachedTypecheckFile(testPath: string): boolean {
405+
_isCachedTypecheckFile(testPath: string): boolean {
406406
return !!this.typecheckFilesList && this.typecheckFilesList.includes(testPath)
407407
}
408408

@@ -430,7 +430,7 @@ export class TestProject {
430430
* Test if a file matches the test globs. This does the actual glob matching if the test is not cached, unlike `isCachedTestFile`.
431431
*/
432432
public matchesTestGlob(moduleId: string, source?: () => string): boolean {
433-
if (this.isCachedTestFile(moduleId)) {
433+
if (this._isCachedTestFile(moduleId)) {
434434
return true
435435
}
436436
const relativeId = relative(this.config.dir || this.config.root, moduleId)

packages/vitest/src/node/specifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export class VitestSpecifications {
2121

2222
const specs: TestSpecification[] = []
2323
for (const project of this.vitest.projects) {
24-
if (project.isCachedTestFile(moduleId)) {
24+
if (project._isCachedTestFile(moduleId)) {
2525
specs.push(project.createSpecification(moduleId))
2626
}
27-
if (project.isCachedTypecheckFile(moduleId)) {
27+
if (project._isCachedTypecheckFile(moduleId)) {
2828
specs.push(project.createSpecification(moduleId, [], 'typescript'))
2929
}
3030
}

packages/vitest/src/node/watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class VitestWatcher {
123123
if (!projects.length) {
124124
// if there are no modules it's possible that server was restarted
125125
// we don't have information about importers anymore, so let's check if the file is a test file at least
126-
if (this.vitest.state.filesMap.has(filepath) || this.vitest.projects.some(project => project.isCachedTestFile(filepath))) {
126+
if (this.vitest.state.filesMap.has(filepath) || this.vitest.projects.some(project => project._isCachedTestFile(filepath))) {
127127
this.changedTests.add(filepath)
128128
return true
129129
}
@@ -142,7 +142,7 @@ export class VitestWatcher {
142142
this.invalidates.add(filepath)
143143

144144
// one of test files that we already run, or one of test files that we can run
145-
if (this.vitest.state.filesMap.has(filepath) || project.isCachedTestFile(filepath)) {
145+
if (this.vitest.state.filesMap.has(filepath) || project._isCachedTestFile(filepath)) {
146146
this.changedTests.add(filepath)
147147
files.push(filepath)
148148
continue

0 commit comments

Comments
 (0)