Skip to content

Commit

Permalink
Fix/crash stagingdir (#215)
Browse files Browse the repository at this point in the history
* fix: fixes crash when stagingFolderPath and stagingDir is not present

* fix: fixes crash when stagingFolderPath and stagingDir is not present

* Adds important missing method t mock node

* fix

* udpate bsc
  • Loading branch information
georgejecook authored Feb 21, 2023
1 parent ddb57d4 commit c2e5b30
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@types/node": "^17.0.29",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"brighterscript": "0.61.2",
"brighterscript": "^0.61.3",
"chai": "^4.2.0",
"chai-subset": "^1.6.0",
"coveralls": "^3.0.0",
Expand Down Expand Up @@ -110,4 +110,4 @@
"ts"
]
}
}
}
12 changes: 9 additions & 3 deletions bsc-plugin/src/lib/rooibos/RooibosSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TestSuiteBuilder } from './TestSuiteBuilder';
import { RawCodeStatement } from './RawCodeStatement';
import type { FileFactory } from './FileFactory';
import type { TestSuite } from './TestSuite';
import { diagnosticErrorNoMainFound as diagnosticWarnNoMainFound } from '../utils/Diagnostics';
import { diagnosticErrorNoMainFound as diagnosticWarnNoMainFound, diagnosticNoStagingDir } from '../utils/Diagnostics';
import undent from 'undent';
import { BrsTranspileState } from 'brighterscript/dist/parser/BrsTranspileState';
import * as fsExtra from 'fs-extra';
Expand Down Expand Up @@ -76,8 +76,14 @@ export class RooibosSession {
}
if (!mainFunction) {
diagnosticWarnNoMainFound(files[0]);
const filePath = path.join(this._builder.options.stagingDir, 'source/rooibosMain.brs');
fsExtra.writeFileSync(filePath, `function main()\n Rooibos_init()\nend function`);
if (!this._builder.options.stagingDir && !this._builder.options.stagingFolderPath) {
console.error('this plugin requires that stagingDir or the deprecated stagingFolderPath bsconfig option is set');
diagnosticNoStagingDir(files[0]);
} else {
const filePath = path.join(this._builder.options.stagingDir ?? this._builder.options.stagingFolderPath, 'source/rooibosMain.brs');
fsExtra.writeFileSync(filePath, `function main()\n Rooibos_init()\nend function`);

}
}
}

Expand Down
9 changes: 9 additions & 0 deletions bsc-plugin/src/lib/utils/Diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,12 @@ export function diagnosticCorruptTestProduced(file: BrsFile, annotation: Annotat
annotation
);
}

export function diagnosticNoStagingDir(file: BscFile) {
addDiagnostic(
file,
2221,
`The bsconfig must define stagingDir, or the deprecated stagingFolderPath options`, 1, 1, 1, 1, DiagnosticSeverity.Error
);
}

2 changes: 1 addition & 1 deletion bsc-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class RooibosPlugin implements CompilerPlugin {
return;
}

console.log('processing ', file.pkgPath);
// console.log('processing ', file.pkgPath);
if (isBrsFile(file)) {
if (this.session.processFile(file)) {
//
Expand Down
4 changes: 4 additions & 0 deletions framework/src/source/Utils.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace rooibos.utils
return m._subType
end function

function isSubType(name)
return false
end function

function createObject(nodeType)
node = new rooibos.utils.MockNode("", nodeType)
m.createdNodes.push(node)
Expand Down

0 comments on commit c2e5b30

Please sign in to comment.