UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 993 B
import e from"../../../utils/helpers/get-dir-name.mjs";import t from"../../cli/logger.mjs";import{access as n,readFile as r,readdir as i,stat as a}from"node:fs/promises";import o from"node:path";const s=e(import.meta.url),c=new Set([`.html`,`.mustache`]),l=async e=>{try{return await n(e),!0}catch{return!1}},u=e=>{let t=o.extname(e);return c.has(t)?e.slice(0,-t.length):null},d=async(e,n,s=!0,c=!1,d=!1)=>{if(!await l(e))return;let f=(await i(e,{withFileTypes:!0})).filter(e=>e.isFile()).map(e=>e.name).toSorted();for(let i of f){let l=u(i);if(!l||!s&&n[l])continue;let f=o.join(e,i),[p,m]=await Promise.all([r(f,`utf-8`),a(f)]);n[l]={html:p,lastModified:m.mtime.toISOString()},d&&t.info(`Prepared email template:`,t.color.green(i),{silent:c})}},f=async e=>{let t=e.silent??!1,n=e.verbose??!1,r={},i=e.config.email.templates.directory,a=o.join(s,`../../../../templates`);return await d(i,r,!0,t,n),await d(a,r,!1,t,n),r};export{f as default}; //# sourceMappingURL=load-email-templates.mjs.map