UNPKG

adr

Version:

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

35 lines 3.31 kB
let findInFiles = require('find-in-files'); let Table = require('table'); import SearchListGenerateBuilder from './base/SearchListGenerateBuilder'; import Config from './Config'; import Utils from './utils'; import StatusHelper from './StatusHelper'; let savePath = Config.getSavePath(); function buildTocBodyFun(index, decision, file, bodyString) { let lastStatus = StatusHelper.getLatestStatus(savePath + file.relativePath); let newItem = [index + '.' + decision, lastStatus]; return bodyString.push(newItem); } export function search(keywords) { findInFiles.find({ 'term': keywords, 'flags': 'ig' }, savePath, '.(md|adoc|asciidoc)$') .then(results => { let files = []; for (let result in results) { files.push({ relativePath: result.substring(savePath.length, result.length) }); } let listGenerateBuilder = new SearchListGenerateBuilder(savePath); let i18n = Utils.getI18n(); let tableData = [i18n.decision, i18n.lastStatus]; let searchResults = listGenerateBuilder .setStart(tableData) .setFiles(files) .setEnd() .setBody(buildTocBodyFun) .build(); console.log(Table.table(searchResults)); return Table.table(searchResults); }); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VhcmNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9zZWFyY2gudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsSUFBSSxXQUFXLEdBQUcsT0FBTyxDQUFDLGVBQWUsQ0FBQyxDQUFBO0FBQzFDLElBQUksS0FBSyxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FBQTtBQUU1QixPQUFPLHlCQUF5QixNQUFNLGtDQUFrQyxDQUFBO0FBQ3hFLE9BQU8sTUFBTSxNQUFNLFVBQVUsQ0FBQTtBQUM3QixPQUFPLEtBQUssTUFBTSxTQUFTLENBQUE7QUFDM0IsT0FBTyxZQUFZLE1BQU0sZ0JBQWdCLENBQUE7QUFFekMsSUFBSSxRQUFRLEdBQUcsTUFBTSxDQUFDLFdBQVcsRUFBRSxD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