Skip to content

Commit

Permalink
Config for force transpile brs file (#573)
Browse files Browse the repository at this point in the history
* Add in configuration option forceBrighterScript

* Rename flag to transpileBrs

* Fix spacing

* Update cli with transpile-brs option

* Rename transpileBrs to allowBrighterScriptInBrightScript

* Rename transpile-br to allow-brighterscript-in-brightscript

* Revert "Rename transpile-br to allow-brighterscript-in-brightscript"

This reverts commit 6a84909.

* Feedback from PR

Co-authored-by: Bronley Plumb <bronley@gmail.com>
  • Loading branch information
justinMBullard and TwitchBronBron committed May 23, 2022
1 parent cc93e20 commit fc1f961
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/BsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,10 @@ export interface BsConfig {
* @default true
*/
sourceMap?: boolean;

/**
* Allow brighterscript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled.
* @default false
*/
allowBrighterScriptInBrightScript?: boolean;
}
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let options = yargs
.help('help', 'View help information about this tool.')
.option('create-package', { type: 'boolean', defaultDescription: 'true', description: 'Creates a zip package. This setting is ignored when deploy is enabled.' })
.option('source-map', { type: 'boolean', defaultDescription: 'false', description: 'Enables generating sourcemap files, which allow debugging tools to show the original source code while running the emitted files.' })
.option('allow-brighterscript-in-brightscript', { alias: 'allow-brighter-script-in-bright-script', type: 'boolean', defaultDescription: 'false', description: 'Allow brighterscript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled..' })
.option('cwd', { type: 'string', description: 'Override the current working directory.' })
.option('copy-to-staging', { type: 'boolean', defaultDescription: 'true', description: 'Copy project files into the staging folder, ready to be packaged.' })
.option('diagnostic-level', { type: 'string', defaultDescription: '"warn"', description: 'Specify what diagnostic types should be printed to the console. Value can be "error", "warn", "hint", "info".' })
Expand Down
2 changes: 1 addition & 1 deletion src/files/BrsFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class BrsFile {
this.extension = util.getExtension(this.srcPath);

//all BrighterScript files need to be transpiled
if (this.extension?.endsWith('.bs')) {
if (this.extension?.endsWith('.bs') || program?.options?.allowBrighterScriptInBrightScript) {
this.needsTranspiled = true;
this.parseMode = ParseMode.BrighterScript;
}
Expand Down
1 change: 1 addition & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export class Util {
config.autoImportComponentScript = config.autoImportComponentScript === true ? true : false;
config.showDiagnosticsInConsole = config.showDiagnosticsInConsole === false ? false : true;
config.sourceRoot = config.sourceRoot ? standardizePath(config.sourceRoot) : undefined;
config.allowBrighterScriptInBrightScript = config.allowBrighterScriptInBrightScript === true ? true : false;
config.emitDefinitions = config.emitDefinitions === true ? true : false;
if (typeof config.logLevel === 'string') {
config.logLevel = LogLevel[(config.logLevel as string).toLowerCase()];
Expand Down

0 comments on commit fc1f961

Please sign in to comment.