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

horiuchi / dtsgenerator / 5572977410

pending completion
5572977410

Pull #555

github

web-flow
Merge 0bee8e546 into 24d8037fd
Pull Request #555: Add support for additionalProperties: false on empty objects

677 of 779 branches covered (86.91%)

2 of 2 new or added lines in 1 file covered. (100.0%)

1117 of 1227 relevant lines covered (91.04%)

4522.19 hits per line

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

0.0
/src/cli.ts
1
import * as fs from 'fs';
2
import { dirname } from 'path';
3
import opts, { initialize } from './commandOptions';
4
import dtsgenerator, {
5
    Schema,
6
    readSchemaFromStdin,
7
    readSchemasFromFile,
8
    readSchemaFromUrl,
9
} from './core';
10
import config, { setConfig, showConfig } from './core/config';
11
import { readConfig } from './utils';
12

13
async function loadContents(): Promise<Schema[]> {
14
    let contents: Schema[] = [];
×
15
    const ps: Promise<void>[] = [];
×
16
    if (config.input.stdin) {
×
17
        ps.push(
×
18
            readSchemaFromStdin().then((s) => {
19
                contents.push(s);
×
20
            })
21
        );
22
    }
23
    for (const pattern of config.input.files) {
×
24
        ps.push(
×
25
            readSchemasFromFile(pattern).then((ss) => {
26
                contents = contents.concat(ss);
×
27
            })
28
        );
29
    }
30
    for (const url of config.input.urls) {
×
31
        ps.push(
×
32
            readSchemaFromUrl(url).then((s) => {
33
                contents.push(s);
×
34
            })
35
        );
36
    }
37
    await Promise.all(ps);
×
38
    return contents;
×
39
}
40

41
async function exec(): Promise<void> {
42
    const command = initialize(process.argv);
×
43
    const pc = readConfig(opts);
×
44
    setConfig(pc);
×
45

46
    if (opts.info) {
×
47
        const version = command.opts().version as string;
×
48
        await showConfig(version, config);
×
49
        return;
×
50
    }
51

52
    const contents = await loadContents();
×
53
    const result = await dtsgenerator({
×
54
        contents,
55
    });
56
    if (opts.out) {
×
57
        fs.mkdirSync(dirname(opts.out), { recursive: true });
×
58
        fs.writeFileSync(opts.out, result, { encoding: 'utf-8' });
×
59
    } else {
60
        console.log(result);
×
61
    }
62
}
63
exec().catch((err: Error) => {
×
64
    console.error(err.stack ?? err);
×
65
    process.exitCode = 1;
×
66
});
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