release: WRNexusJS 0.4.0
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import type { PluginInput, WrnexusPlugin } from "./types.ts";
|
||||
|
||||
export function definePlugin(plugin: WrnexusPlugin): WrnexusPlugin {
|
||||
if (!plugin?.name || !/^[a-z0-9@][a-z0-9@/._-]*$/i.test(plugin.name)) {
|
||||
throw new Error("WRN-PLUGIN-NAME: plugins require a stable package-style name.");
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
export function flattenPlugins(input: PluginInput, output: WrnexusPlugin[] = []): WrnexusPlugin[] {
|
||||
if (!input) return output;
|
||||
if (Array.isArray(input)) {
|
||||
for (const entry of input) flattenPlugins(entry, output);
|
||||
} else {
|
||||
output.push(definePlugin(input));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user