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

rokucommunity / brighterscript / #13071

25 Sep 2024 04:16PM UTC coverage: 86.525% (-1.4%) from 87.933%
#13071

push

web-flow
Merge c610b9e4e into 56dcaaa63

10903 of 13389 branches covered (81.43%)

Branch coverage included in aggregate %.

6936 of 7533 new or added lines in 100 files covered. (92.07%)

83 existing lines in 18 files now uncovered.

12548 of 13714 relevant lines covered (91.5%)

27591.0 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
675✔
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)) {
675!
NEW
17
            return;
×
18
        }
19
        if (isBrsFile(this.event.file)) {
675✔
20
            this.serializeBrsFile(this.event.file);
637✔
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[] = [];
637✔
30
        const serialized = file.serialize();
637✔
31

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