UNPKG

adr

Version:

轻量级架构记录工具 - Command-line tools for working with Architecture Decision Records

40 lines 3.62 kB
let fs = require('fs'); import Config from '../Config'; import getAdrFiles from '../helpers/getAdrFiles'; import MdHelper from '../helpers/MdHelper'; import AsciidocHelper from '../helpers/AsciidocHelper'; import BasicOutput from './BasicOutput'; const fileExt = Config.getDocExtension(); class HtmlBuilder extends BasicOutput { buildFunc() { let files = getAdrFiles(); let path = this.path; files.forEach(function (file) { let fileName = file.relativePath; if ((fileName === 'README.md' || fileName.indexOf('.md') === -1) && (fileName === 'README.adoc' || fileName.indexOf('.adoc') === -1) && (fileName === 'README.asciidoc' || fileName.indexOf('.asciidoc') === -1)) { return; } let fileData = fs.readFileSync(path + fileName, 'utf8'); fs.appendFileSync('output.' + fileExt, fileData + '\n\n'); }); } buildContent() { this.buildFunc(); let fileData = fs.readFileSync('output.' + fileExt, 'utf-8'); fs.unlinkSync('output.' + fileExt); if (fileExt === 'adoc' || fileExt === 'asciidoc') { this.result = AsciidocHelper.asciidocRender(fileData); } else { this.result = MdHelper.mdRender(fileData); } return this.result; } output() { fs.writeFileSync(this.workDir + '/export.html', this.result, 'utf-8'); } } export default HtmlBuilder; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSHRtbEJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbGliL291dHB1dC9IdG1sQnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLEVBQUUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7QUFFdEIsT0FBTyxNQUFNLE1BQU0sV0FBVyxDQUFBO0FBQzlCLE9BQU8sV0FBVyxNQUFNLHdCQUF3QixDQUFBO0FBQ2hELE9BQU8sUUFBUSxNQUFNLHFCQUFxQixDQUFBO0FBQzFDLE9BQU8sY0FBYyxNQUFNLDJCQUEyQixDQUFBO0F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