UNPKG

@baseplate-dev/core-generators

Version:

Core generators for Baseplate

28 lines 1.22 kB
import { enhanceErrorWithContext } from '@baseplate-dev/utils'; import { renderTextTemplateFileAction } from './render-text-template-file-action.js'; export function renderTextTemplateGroupAction({ group, paths, variables, options, }) { return { execute: async (builder) => { for (const [key, template] of Object.entries(group)) { const destination = paths[key]; if (destination === undefined) { throw new Error(`Missing destination path for template "${key}"`); } try { await builder.apply(renderTextTemplateFileAction({ template, destination, variables: variables && typeof variables === 'object' ? variables[key] : undefined, options: options?.[key], })); } catch (error) { throw enhanceErrorWithContext(error, `Failed to render template "${key}"`); } } }, }; } //# sourceMappingURL=render-text-template-group-action.js.map