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

rokucommunity / brighterscript / #12929

13 Aug 2024 05:02PM UTC coverage: 86.193% (-1.7%) from 87.933%
#12929

push

web-flow
Merge 58ad447a2 into 0e968f1c3

10630 of 13125 branches covered (80.99%)

Branch coverage included in aggregate %.

6675 of 7284 new or added lines in 99 files covered. (91.64%)

84 existing lines in 18 files now uncovered.

12312 of 13492 relevant lines covered (91.25%)

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

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