-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathparse.ts
More file actions
31 lines (28 loc) · 1.15 KB
/
parse.ts
File metadata and controls
31 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { BrsFile, BsConfig } from '../../src';
import type { TargetOptions } from '../target-runner';
module.exports = async (options: TargetOptions) => {
const { suite, name, version, fullName, brighterscript, projectPath, suiteOptions } = options;
const { ProgramBuilder, Parser } = brighterscript;
const builder = new ProgramBuilder();
//run the first run
await builder.run({
cwd: projectPath,
createPackage: false,
copyToStaging: false,
noEmit: true,
//disable diagnostic reporting (they still get collected)
diagnosticFilters: ['**/*'],
logLevel: 'error',
...options.additionalConfig
} as BsConfig & Record<string, any>);
//collect all the brighterscript files
const brsFiles = Object.values(builder.program!.files as Record<string, BrsFile>).filter(x => x.extension === '.brs' || x.extension === '.bs') as Array<BrsFile>;
if (brsFiles.length === 0) {
throw new Error('No files found in program');
}
suite.add(fullName, () => {
for (let brsFile of brsFiles) {
Parser.parse(brsFile.parser.tokens);
}
}, suiteOptions);
};