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

typeorm / typeorm / 13573761448

27 Feb 2025 06:53PM UTC coverage: 72.376% (+0.007%) from 72.369%
13573761448

push

github

web-flow
refactor: use ansis instead of chalk (#11263)

8657 of 12650 branches covered (68.43%)

Branch coverage included in aggregate %.

35 of 52 new or added lines in 11 files covered. (67.31%)

4 existing lines in 3 files now uncovered.

17895 of 24036 relevant lines covered (74.45%)

144036.91 hits per line

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

30.43
/src/commands/SubscriberCreateCommand.ts
1
import ansi from "ansis"
248✔
2
import path from "path"
248✔
3
import yargs from "yargs"
4
import { PlatformTools } from "../platform/PlatformTools"
248✔
5
import { CommandUtils } from "./CommandUtils"
248✔
6

7
/**
8
 * Generates a new subscriber.
9
 */
10
export class SubscriberCreateCommand implements yargs.CommandModule {
248✔
11
    command = "subscriber:create <path>"
248✔
12
    describe = "Generates a new subscriber."
248✔
13

14
    builder(args: yargs.Argv) {
15
        return args.positional("path", {
×
16
            type: "string",
17
            describe: "Path of the subscriber file",
18
            demandOption: true,
19
        })
20
    }
21

22
    async handler(args: yargs.Arguments) {
23
        try {
×
24
            const fullPath = (args.path as string).startsWith("/")
×
25
                ? (args.path as string)
26
                : path.resolve(process.cwd(), args.path as string)
27
            const filename = path.basename(fullPath)
×
28
            const fileContent = SubscriberCreateCommand.getTemplate(filename)
×
29
            const fileExists = await CommandUtils.fileExists(fullPath + ".ts")
×
30
            if (fileExists) {
×
NEW
31
                throw new Error(`File "${fullPath}.ts" already exists`)
×
32
            }
33
            await CommandUtils.createFile(fullPath + ".ts", fileContent)
×
34
            console.log(
×
35
                ansi.green(
36
                    `Subscriber ${ansi.blue`${fullPath}.ts`} has been created successfully.`,
37
                ),
38
            )
39
        } catch (error) {
NEW
40
            PlatformTools.logCmdErr("Error during subscriber creation:", error)
×
UNCOV
41
            process.exit(1)
×
42
        }
43
    }
44

45
    // -------------------------------------------------------------------------
46
    // Protected Static Methods
47
    // -------------------------------------------------------------------------
48

49
    /**
50
     * Gets contents of the entity file.
51
     */
52
    protected static getTemplate(name: string): string {
53
        return `import { EventSubscriber, EntitySubscriberInterface } from "typeorm"
×
54

55
@EventSubscriber()
56
export class ${name} implements EntitySubscriberInterface {
57

58
}
59
`
60
    }
61
}
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