diff --git a/src/BsConfig.ts b/src/BsConfig.ts index 941761259..152570086 100644 --- a/src/BsConfig.ts +++ b/src/BsConfig.ts @@ -16,6 +16,12 @@ export interface BsConfig { bs_const?: Record; }; + /** + * when set, bsconfig.json loading is disabled + */ + noProject?: boolean; + + /** * Relative or absolute path to another bsconfig.json file that this file should import and then override. * Prefix with a question mark (?) to prevent throwing an exception if the file does not exist. diff --git a/src/ProgramBuilder.ts b/src/ProgramBuilder.ts index 3d0646255..434cb5ad9 100644 --- a/src/ProgramBuilder.ts +++ b/src/ProgramBuilder.ts @@ -99,7 +99,9 @@ export class ProgramBuilder { this.isRunning = true; try { this.options = util.normalizeAndResolveConfig(options); - if (this.options.project) { + if (this.options.noProject) { + this.logger.log(`'no-project' flag is set so bsconfig.json loading is disabled'`); + } else if (this.options.project) { this.logger.log(`Using config file: "${this.options.project}"`); } else { this.logger.log(`No bsconfig.json file found, using default options`); diff --git a/src/cli.ts b/src/cli.ts index 6a23b2d19..378d9983c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -30,6 +30,7 @@ let options = yargs .option('files', { type: 'array', description: 'The list of files (or globs) to include in your project. Be sure to wrap these in double quotes when using globs.' }) .option('host', { type: 'string', description: 'The host used when deploying to a Roku.' }) .option('ignore-error-codes', { type: 'array', description: 'A list of error codes that the compiler should NOT emit, even if encountered.' }) + .option('no-project', { type: 'boolean', defaultDescription: 'false', description: 'When set, bsconfig.json loading is disabled', alias: ['noproject', 'noProject'] }) .option('log-level', { type: 'string', defaultDescription: '"log"', description: 'The log level. Value can be "error", "warn", "log", "info", "debug".' }) .option('out-file', { type: 'string', description: 'Path to the zip folder containing the bundled project. Defaults to `./out/[YOUR_ROOT_FOLDER_NAME].zip' }) .option('password', { type: 'string', description: 'The password for deploying to a Roku.' }) diff --git a/src/util.ts b/src/util.ts index 9fb8d575d..d8754afd2 100644 --- a/src/util.ts +++ b/src/util.ts @@ -297,12 +297,17 @@ export class Util { public normalizeAndResolveConfig(config: BsConfig) { let result = this.normalizeConfig({}); - //if no options were provided, try to find a bsconfig.json file - if (!config || !config.project) { - result.project = this.getConfigFilePath(config?.cwd); + if (config?.noProject) { + return result; + } + + result.project = null; + if (config?.project) { + result.project = config?.project; } else { - //use the config's project link - result.project = config.project; + if (config?.cwd) { + result.project = this.getConfigFilePath(config?.cwd); + } } if (result.project) { let configFile = this.loadConfigFile(result.project, null, config?.cwd);