From 1a49edc21c7248fb8571a47ad46fa99a5cd2eee4 Mon Sep 17 00:00:00 2001 From: Christopher Dwyer-Perkins Date: Wed, 15 Jan 2025 12:06:40 -0400 Subject: [PATCH] Code clean up and removed unessisary props following the structure change --- bsc-plugin/src/lib/rooibos/FileFactory.ts | 42 +++++++---------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/bsc-plugin/src/lib/rooibos/FileFactory.ts b/bsc-plugin/src/lib/rooibos/FileFactory.ts index 36dd202f..165c1d31 100644 --- a/bsc-plugin/src/lib/rooibos/FileFactory.ts +++ b/bsc-plugin/src/lib/rooibos/FileFactory.ts @@ -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'; @@ -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 = []; @@ -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 }; @@ -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')) @@ -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(`