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

rokucommunity / brighterscript / #13688

03 Feb 2025 05:08PM UTC coverage: 86.753% (-1.4%) from 88.185%
#13688

push

web-flow
Merge 1130cc722 into 4afb6f658

12476 of 15203 branches covered (82.06%)

Branch coverage included in aggregate %.

7751 of 8408 new or added lines in 101 files covered. (92.19%)

85 existing lines in 17 files now uncovered.

13398 of 14622 relevant lines covered (91.63%)

34300.24 hits per line

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

87.5
/src/bscPlugin/serialize/FileSerializer.ts
1
import { isAssetFile, isBrsFile, isXmlFile } from '../../astUtils/reflection';
1✔
2
import type { AssetFile } from '../../files/AssetFile';
3
import type { BrsFile } from '../../files/BrsFile';
4
import type { XmlFile } from '../../files/XmlFile';
5
import type { SerializedFile, SerializeFileEvent } from '../../interfaces';
6

7
export class FileSerializer {
1✔
8
    constructor(
9
        private event: SerializeFileEvent
727✔
10
    ) {
11

12
    }
13

14
    public process() {
15
        //if there's already a result for this file, do nothing
16
        if (this.event.result.has(this.event.file)) {
727!
NEW
17
            return;
×
18
        }
19
        this.event.scope?.linkSymbolTable();
727!
20
        if (isBrsFile(this.event.file)) {
727✔
21
            this.serializeBrsFile(this.event.file);
689✔
22
        } else if (isXmlFile(this.event.file)) {
38✔
23
            this.serializeXmlFile(this.event.file);
27✔
24
        } else if (isAssetFile(this.event.file)) {
11!
25
            this.serializeAssetFile(this.event.file);
11✔
26
        }
27
        this.event.scope?.unlinkSymbolTable();
727!
28
    }
29

30
    private serializeBrsFile(file: BrsFile) {
31
        const result: SerializedFile[] = [];
689✔
32
        const serialized = file.serialize();
689✔
33

34
        if (typeof serialized.code === 'string') {
689!
35
            result.push({
689✔
36
                pkgPath: file.pkgPath,
37
                data: Buffer.from(serialized.code)
38
            });
39
        }
40
        if (serialized.map) {
689✔
41
            result.push({
355✔
42
                pkgPath: file.pkgPath + '.map',
43
                data: Buffer.from(serialized.map.toString())
44
            });
45
        }
46
        if (typeof serialized.typedef === 'string') {
689✔
47
            result.push({
21✔
48
                pkgPath: file.pkgPath.replace(/\.brs$/i, '.d.bs'),
49
                data: Buffer.from(serialized.typedef)
50
            });
51
        }
52

53
        this.event.result.set(file, result);
689✔
54
    }
55

56
    private serializeXmlFile(file: XmlFile) {
57
        const result: SerializedFile[] = [];
27✔
58
        const serialized = file.serialize();
27✔
59
        if (typeof serialized.code === 'string') {
27!
60
            result.push({
27✔
61
                pkgPath: file.pkgPath,
62
                data: Buffer.from(serialized.code)
63
            });
64
        }
65
        if (serialized.map) {
27✔
66
            result.push({
2✔
67
                pkgPath: file.pkgPath + '.map',
68
                data: Buffer.from(serialized.map.toString())
69
            });
70
        }
71
        this.event.result.set(file, result);
27✔
72
    }
73

74
    private serializeAssetFile(file: AssetFile) {
75
        this.event.result.set(file, [{
11✔
76
            pkgPath: file.pkgPath,
77
            data: file.data.value
78
        }]);
79
    }
80
}
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