(pluginCtx: PluginCtx, id: string)
| 32 | }; |
| 33 | |
| 34 | export const runPluginLoad = async (pluginCtx: PluginCtx, id: string) => { |
| 35 | for (const plugin of pluginCtx.config?.plugins ?? []) { |
| 36 | if (isFunction(plugin.load)) { |
| 37 | try { |
| 38 | const results = plugin.load(id, pluginCtx); |
| 39 | |
| 40 | if (results != null) { |
| 41 | if (isFunction((results as any).then)) { |
| 42 | const promiseResults = await results; |
| 43 | if (promiseResults != null) { |
| 44 | return promiseResults as string; |
| 45 | } |
| 46 | } else if (isString(results)) { |
| 47 | return results; |
| 48 | } |
| 49 | } |
| 50 | } catch (e: any) { |
| 51 | catchError(pluginCtx.diagnostics, e); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // default load() |
| 57 | return pluginCtx.fs.readFile(id); |
| 58 | }; |
| 59 | |
| 60 | /** |
| 61 | * returns a subset of the baseline array of strings |
no test coverage detected