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

rokucommunity / brighterscript / #13112

30 Sep 2024 04:35PM UTC coverage: 86.842% (-1.4%) from 88.193%
#13112

push

web-flow
Merge 25fc06528 into 3a2dc7282

11525 of 14034 branches covered (82.12%)

Branch coverage included in aggregate %.

6990 of 7581 new or added lines in 100 files covered. (92.2%)

83 existing lines in 18 files now uncovered.

12691 of 13851 relevant lines covered (91.63%)

29447.3 hits per line

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

89.13
/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
681✔
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)) {
681!
NEW
17
            return;
×
18
        }
19
        if (isBrsFile(this.event.file)) {
681✔
20
            this.serializeBrsFile(this.event.file);
643✔
21
        } else if (isXmlFile(this.event.file)) {
38✔
22
            this.serializeXmlFile(this.event.file);
27✔
23
        } else if (isAssetFile(this.event.file)) {
11!
24
            this.serializeAssetFile(this.event.file);
11✔
25
        }
26
    }
27

28
    private serializeBrsFile(file: BrsFile) {
29
        const result: SerializedFile[] = [];
643✔
30
        const serialized = file.serialize();
643✔
31

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

51
        this.event.result.set(file, result);
643✔
52
    }
53

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

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