get-markdown.ts 540 B

12345678910111213141516
  1. import fs from 'fs';
  2. import path from 'path';
  3. import { getStatus } from './get-status';
  4. export const getMarkdown = async(projectDirRoot: string, templateId: string, locale: string): Promise<string> => {
  5. const tplDir = path.resolve(projectDirRoot, 'dist', templateId, locale);
  6. const { isTemplateExists } = await getStatus(tplDir);
  7. if (!isTemplateExists) throw new Error("'template.md does not exist.");
  8. const markdownPath = path.resolve(tplDir, 'template.md');
  9. return fs.readFileSync(markdownPath, { encoding: 'utf-8' });
  10. };