From 82bcc72d2133d305e6d2be4aace26cbef52d8ed0 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Tue, 2 Jul 2024 14:50:21 -0400 Subject: [PATCH] Fix runtime loading --- src/common/runtime.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common/runtime.ts b/src/common/runtime.ts index 96dcb2d..2e7fae6 100644 --- a/src/common/runtime.ts +++ b/src/common/runtime.ts @@ -30,7 +30,7 @@ let scrollRuntime: IRuntime | null = null; export function log(s: unknown, level: LogLevel = LogLevel.Notice): void { getRuntime().then(({ file }) => { - const raw = typeof s === 'string' ? s : JSON.stringify(s, null, 2); + const raw = JSON.stringify(s, null, 2); const output = `${level}: ${raw}\n`; const outputFile = (level === LogLevel.Error) @@ -85,13 +85,16 @@ export async function getRuntime(): Promise { const pkg = await import(path); if ('default' in pkg) { scrollRuntime = pkg.default; - if (scrollRuntime !== null) { - return Promise.resolve(scrollRuntime); - } } + + if (scrollRuntime !== null) { + return Promise.resolve(scrollRuntime); + } + + return Promise.reject('Missing default import'); } - return Promise.reject('Missing default import'); + return Promise.resolve(scrollRuntime); } /**