Skip to content

Commit

Permalink
Code clean up and removed unessisary props following the structure ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
chrisdp committed Jan 15, 2025
1 parent 4fd2173 commit 1a49edc
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions bsc-plugin/src/lib/rooibos/FileFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BrsFile, Program, XmlFile } from 'brighterscript';
import type { BrsFile, BscFile, Program, XmlFile } from 'brighterscript';
import { standardizePath as s } from 'brighterscript';
import * as path from 'path';
import * as fs from 'fs';
Expand Down Expand Up @@ -30,27 +30,8 @@ export class FileFactory {
this.coverageComponentBrsTemplate = fs.readFileSync(path.join(this.options.frameworkSourcePath, '/source/rooibos/CodeCoverage.brs'), 'utf8');
}

private frameworkFileNames = [
'BaseTestSuite',
'CommonUtils',
'Coverage',
'Matchers',
'Rooibos',
'RuntimeConfig',
'Stats',
'Test',
'TestGroup',
'BaseTestReporter',
'ConsoleTestReporter',
'JUnitTestReporter',
'TestResult',
'TestRunner',
'Utils'
];

private targetPath = 'source/rooibos/';
private targetCompsPath = 'components/rooibos/';
public addedFrameworkFiles = [];
public addedSourceFrameworkFilePaths: string[] = [];
public addedFrameworkFiles: BscFile[] = [];

public addFrameworkFiles(program: Program) {
this.addedFrameworkFiles = [];
Expand All @@ -67,9 +48,12 @@ export class FileFactory {
onlyFiles: true
});

console.log('globedFiles', globedFiles);

for (let filePath of globedFiles) {
if (/^source[/\\]rooibos[/\\]/g.test(filePath)) {
// Save a list of all source files added to the program
// to be imported by node test components
this.addedSourceFrameworkFilePaths.push(filePath);
}
let sourcePath = path.resolve(this.options.frameworkSourcePath, filePath);
let fileContents = fs.readFileSync(sourcePath, 'utf8').toString();
let entry = { src: sourcePath, dest: filePath };
Expand All @@ -80,7 +64,7 @@ export class FileFactory {

let entry = {
src: s`${this.options.frameworkSourcePath}/components/RooibosScene.xml`,
dest: s`${this.targetCompsPath}/components/RooibosScene.xml`
dest: s`components/rooibos/RooibosScene.xml`
};
this.addedFrameworkFiles.push(
program.setFile(entry, this.createTestXML('RooibosScene', 'Scene'))
Expand All @@ -89,8 +73,8 @@ export class FileFactory {

public createTestXML(name: string, baseName: string, suite?: TestSuite): string {
let scriptImports = [];
for (let fileName of this.frameworkFileNames) {
scriptImports.push(`<script type="text/brighterscript" uri="pkg:/${this.targetPath}${fileName}.bs" />`);
for (let filePath of this.addedSourceFrameworkFilePaths) {
scriptImports.push(`<script type="text/brighterscript" uri="pkg:/${filePath}" />`);
}

// Add the test spec file rather then relying on auto imports
Expand Down Expand Up @@ -132,8 +116,8 @@ export class FileFactory {

public isIgnoredFile(file: BrsFile | XmlFile): boolean {
let name = file.pkgPath.toLowerCase();
let result = this.frameworkFileNames.find((f) => {
return name === path.join(this.targetPath, `${f}.bs`).toLowerCase();
let result = this.addedFrameworkFiles.find((f) => {
return name === f.pkgPath.toLowerCase();
}
);
return result !== undefined;
Expand Down

0 comments on commit 1a49edc

Please sign in to comment.