Fix runtime loading
All checks were successful
timw4mail/scroll/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2024-07-02 14:50:21 -04:00
parent 32f9ef3bba
commit 82bcc72d21

View File

@ -30,7 +30,7 @@ let scrollRuntime: IRuntime | null = null;
export function log(s: unknown, level: LogLevel = LogLevel.Notice): void { export function log(s: unknown, level: LogLevel = LogLevel.Notice): void {
getRuntime().then(({ file }) => { 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 output = `${level}: ${raw}\n`;
const outputFile = (level === LogLevel.Error) const outputFile = (level === LogLevel.Error)
@ -85,13 +85,16 @@ export async function getRuntime(): Promise<IRuntime> {
const pkg = await import(path); const pkg = await import(path);
if ('default' in pkg) { if ('default' in pkg) {
scrollRuntime = pkg.default; 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);
} }
/** /**