/
githubmirror
/
english-compiler
Обзор
Документация
Войти
/
githubmirror
/
english-compiler
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/codegen/markdownSpecFileChangeWithFeedback.js
33 строки
1 KB
Eugene Cheah
wiring up the codegen
17 фев 2023, 11:33
17 фев 2023, 11:33
e7ea543
Код
Авторство
О чём код?
//-------------------------------------------------- // Dependencies //-------------------------------------------------- const parseMD = require('parse-md').default const fs = require("fs"); const path = require('path'); const specChangeUsingFeedback = require('./segment/specChangeUsingFeedback'); //-------------------------------------------------- // Implementation //-------------------------------------------------- /** * Given the markdown details, generate the full code file * * @param {String} filePath for the full markdown file * * @return Generated code string, wrapped in a promise */ async function markdownSpecFileChangeWithFeedback( filePath, aiSuggestion, userFeedback, prgCallbck = function() {} ) { // Read the file, and split out the metadata + content let fullFileData = await fs.promises.readFile( filePath, "utf8" ); let { metadata, content } = parseMD(fullFileData); // Guess the name if not set, from the first segment of the filename metadata.name = metadata.name || path.basename( filePath ).split(".")[0]; metadata.spec = content; // Forward it to the actual function that processes it return await specChangeUsingFeedback( metadata, aiSuggestion, userFeedback ); } module.exports = markdownSpecFileChangeWithFeedback;