UNPKG

markdown-code

Version:

Keep code examples in Markdown synchronized with actual source files

47 lines (45 loc) 1.16 kB
import { format, hasErrors, hasIssues } from "./chunk-6OD27PGB.js"; import { syncMarkdownFiles } from "./chunk-LFQPKNTT.js"; import "./chunk-7RDMPJH4.js"; import { getValidatedConfig, handleError, logWarningsAndErrors } from "./chunk-LNSAPIWZ.js"; // src/commands/sync.ts var command = ["sync", "$0"]; var describe = "Update markdown files with snippet content (default)"; var handler = async (argv) => { try { const config = await getValidatedConfig(argv); console.log("Syncing markdown files..."); const result = await syncMarkdownFiles(config); logWarningsAndErrors(result.warnings, result.errors); if (hasIssues(result.fileIssues)) { const formattedOutput = format(result.fileIssues); console.error(formattedOutput); if (hasErrors(result.fileIssues)) { process.exit(1); } } if (result.updated.length > 0) { console.log("Updated files:"); result.updated.forEach((file) => console.log(` ${file}`)); } else { console.log("All files are already in sync."); } } catch (error) { handleError(error); } }; export { command, describe, handler };