Add the HandlerConfig type to the global handler config (#5858)

This commit is contained in:
kevinjeon-g
2023-12-10 15:03:34 -05:00
committed by GitHub
parent 83769165f9
commit fb0f0a86d9
3 changed files with 10 additions and 9 deletions

9
app.ts
View File

@@ -73,9 +73,6 @@ import type {Language, LanguageKey} from './types/languages.interfaces.js';
// Used by assert.ts
global.ce_base_directory = new URL('.', import.meta.url);
// Used by d8.ts
global.handlerConfig = null;
(nopt as any).invalidHandler = (key, val, types) => {
logger.error(
`Command line argument type error for "--${key}=${val}", expected ${types.map(t => typeof t).join(' | ')}`,
@@ -566,7 +563,7 @@ async function main() {
const healthCheckFilePath = ceProps('healthCheckFilePath', false);
// Exported to allow compilers to refer to other existing compilers.
global.handlerConfig = {
global.handler_config = {
compileHandler,
clientOptionsHandler,
storageHandler,
@@ -579,8 +576,8 @@ async function main() {
contentPolicyHeader,
};
const noscriptHandler = new NoScriptHandler(router, global.handlerConfig);
const routeApi = new RouteAPI(router, global.handlerConfig);
const noscriptHandler = new NoScriptHandler(router, global.handler_config);
const routeApi = new RouteAPI(router, global.handler_config);
async function onCompilerChange(compilers) {
if (JSON.stringify(prevCompilers) === JSON.stringify(compilers)) {

View File

@@ -80,7 +80,7 @@ export class D8Compiler extends BaseCompiler {
// Instantiate Java or Kotlin compiler based on the current language.
if (this.lang.id === 'android-java') {
const javaCompiler = global.handlerConfig.compileHandler.findCompiler('java', this.javaId);
const javaCompiler = global.handler_config.compileHandler.findCompiler('java', this.javaId);
outputFilename = javaCompiler.getOutputFilename(preliminaryCompilePath);
const javaOptions = _.compact(
javaCompiler.prepareArguments(
@@ -100,7 +100,7 @@ export class D8Compiler extends BaseCompiler {
javaCompiler.getDefaultExecOptions(),
);
} else if (this.lang.id === 'android-kotlin') {
const kotlinCompiler = global.handlerConfig.compileHandler.findCompiler('kotlin', this.kotlinId);
const kotlinCompiler = global.handler_config.compileHandler.findCompiler('kotlin', this.kotlinId);
outputFilename = kotlinCompiler.getOutputFilename(preliminaryCompilePath);
const kotlinOptions = _.compact(
kotlinCompiler.prepareArguments(

View File

@@ -22,10 +22,14 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import {HandlerConfig} from './handlers/route-api.js';
declare global {
// var is required
// eslint-disable-next-line no-var
/* eslint-disable no-var */
var ce_base_directory: URL;
var handler_config: HandlerConfig;
/* eslint-enable no-var */
}
// Necessary because we're not exporting any actual symbols from this file