• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

typeorm / typeorm / 19549987525

20 Nov 2025 08:11PM UTC coverage: 80.769% (+4.3%) from 76.433%
19549987525

push

github

web-flow
ci: run tests on commits to master and next (#11783)

Co-authored-by: Oleg "OSA413" Sokolov <OSA413@users.noreply.github.com>

26500 of 32174 branches covered (82.36%)

Branch coverage included in aggregate %.

91252 of 113615 relevant lines covered (80.32%)

88980.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/src/util/DirectoryExportedClassesLoader.ts
1
import * as glob from "glob"
26✔
2
import { PlatformTools } from "../platform/PlatformTools"
26✔
3
import { Logger } from "../logger/Logger"
26✔
4
import { importOrRequireFile } from "./ImportUtils"
26✔
5
import { ObjectUtils } from "./ObjectUtils"
26✔
6
import { InstanceChecker } from "./InstanceChecker"
26✔
7

26✔
8
/**
26✔
9
 * Loads all exported classes from the given directory.
26✔
10
 */
26✔
11
export async function importClassesFromDirectories(
26✔
12
    logger: Logger,
43,387✔
13
    directories: string[],
43,387✔
14
    formats = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"],
43,387✔
15
): Promise<Function[]> {
43,387✔
16
    const logLevel = "info"
43,387✔
17
    const classesNotFoundMessage =
43,387✔
18
        "No classes were found using the provided glob pattern: "
43,387✔
19
    const classesFoundMessage = "All classes found using provided glob pattern"
43,387✔
20
    function loadFileClasses(exported: any, allLoaded: Function[]) {
43,387✔
21
        if (
102,705✔
22
            typeof exported === "function" ||
102,705✔
23
            InstanceChecker.isEntitySchema(exported)
73,566✔
24
        ) {
102,705✔
25
            allLoaded.push(exported)
29,437✔
26
        } else if (Array.isArray(exported)) {
102,705✔
27
            exported.forEach((value) => loadFileClasses(value, allLoaded))
43,387✔
28
        } else if (ObjectUtils.isObject(exported)) {
73,268✔
29
            Object.values(exported).forEach((value) =>
28,666✔
30
                loadFileClasses(value, allLoaded),
28,666✔
31
            )
28,666✔
32
        }
28,666✔
33
        return allLoaded
102,705✔
34
    }
102,705✔
35

43,387✔
36
    const allFiles = directories.reduce((allDirs, dir) => {
43,387✔
37
        return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)))
11,421✔
38
    }, [] as string[])
43,387✔
39

43,387✔
40
    if (directories.length > 0 && allFiles.length === 0) {
43,387✔
41
        logger.log(logLevel, `${classesNotFoundMessage} "${directories}"`)
768✔
42
    } else if (allFiles.length > 0) {
43,387✔
43
        logger.log(
10,653✔
44
            logLevel,
10,653✔
45
            `${classesFoundMessage} "${directories}" : "${allFiles}"`,
10,653✔
46
        )
10,653✔
47
    }
10,653✔
48
    const dirPromises = allFiles
43,387✔
49
        .filter((file) => {
43,387✔
50
            const dtsExtension = file.substring(file.length - 5, file.length)
56,399✔
51
            return (
56,399✔
52
                formats.indexOf(PlatformTools.pathExtname(file)) !== -1 &&
56,399✔
53
                dtsExtension !== ".d.ts"
56,399✔
54
            )
56,399✔
55
        })
43,387✔
56
        .map(async (file) => {
43,387✔
57
            const [importOrRequireResult] = await importOrRequireFile(
28,274✔
58
                PlatformTools.pathResolve(file),
28,274✔
59
            )
28,274✔
60
            return importOrRequireResult
28,274✔
61
        })
43,387✔
62

43,387✔
63
    const dirs = await Promise.all(dirPromises)
43,387✔
64

43,387✔
65
    return loadFileClasses(dirs, [])
43,387✔
66
}
43,387✔
67

26✔
68
/**
26✔
69
 * Loads all json files from the given directory.
26✔
70
 */
26✔
71
export function importJsonsFromDirectories(
×
72
    directories: string[],
×
73
    format = ".json",
×
74
): any[] {
×
75
    const allFiles = directories.reduce((allDirs, dir) => {
×
76
        return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)))
×
77
    }, [] as string[])
×
78

×
79
    return allFiles
×
80
        .filter((file) => PlatformTools.pathExtname(file) === format)
×
81
        .map((file) => require(PlatformTools.pathResolve(file)))
×
82
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc