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

rokucommunity / brighterscript / #12716

14 Jun 2024 08:20PM UTC coverage: 85.629% (-2.3%) from 87.936%
#12716

push

web-flow
Merge 94311dc0a into 42db50190

10808 of 13500 branches covered (80.06%)

Branch coverage included in aggregate %.

6557 of 7163 new or added lines in 96 files covered. (91.54%)

83 existing lines in 17 files now uncovered.

12270 of 13451 relevant lines covered (91.22%)

26529.43 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
621✔
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)) {
621!
NEW
17
            return;
×
18
        }
19
        if (isBrsFile(this.event.file)) {
621✔
20
            this.serializeBrsFile(this.event.file);
585✔
21
        } else if (isXmlFile(this.event.file)) {
36✔
22
            this.serializeXmlFile(this.event.file);
26✔
23
        } else if (isAssetFile(this.event.file)) {
10!
24
            this.serializeAssetFile(this.event.file);
10✔
25
        }
26
    }
27

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

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

54
    private serializeXmlFile(file: XmlFile) {
55
        const result: SerializedFile[] = [];
26✔
56
        const serialized = file.serialize();
26✔
57
        if (typeof serialized.code === 'string') {
26!
58
            result.push({
26✔
59
                pkgPath: file.pkgPath,
60
                data: Buffer.from(serialized.code)
61
            });
62
        }
63
        if (serialized.map) {
26✔
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);
26✔
70
    }
71

72
    private serializeAssetFile(file: AssetFile) {
73
        this.event.result.set(file, [{
10✔
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