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

rokucommunity / brighterscript / #13127

01 Oct 2024 04:46PM UTC coverage: 86.842% (-1.4%) from 88.193%
#13127

push

web-flow
Merge abf8e1380 into 3a2dc7282

11554 of 14068 branches covered (82.13%)

Branch coverage included in aggregate %.

7000 of 7592 new or added lines in 100 files covered. (92.2%)

83 existing lines in 18 files now uncovered.

12701 of 13862 relevant lines covered (91.62%)

29528.92 hits per line

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

91.07
/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
687✔
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)) {
687!
NEW
17
            return;
×
18
        }
19
        this.event.scope?.linkSymbolTable();
687✔
20
        if (isBrsFile(this.event.file)) {
687✔
21
            this.serializeBrsFile(this.event.file);
649✔
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();
687✔
28
    }
29

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

34
        if (typeof serialized.code === 'string') {
649!
35
            result.push({
649✔
36
                pkgPath: file.pkgPath,
37
                data: Buffer.from(serialized.code)
38
            });
39
        }
40
        if (serialized.map) {
649✔
41
            result.push({
341✔
42
                pkgPath: file.pkgPath + '.map',
43
                data: Buffer.from(serialized.map.toString())
44
            });
45
        }
46
        if (typeof serialized.typedef === 'string') {
649✔
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);
649✔
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