UNPKG

vue-docgen-cli

Version:

Generate documentation markdown files from VueJs components using the vue-docgen-api.

49 lines 1.69 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.clearCache = exports.findFileCaseInsensitive = exports.mdclean = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const lodash_memoize_1 = __importDefault(require("lodash.memoize")); /** * Replaces returns and tubes to make the input compatible with markdown * also makes sure < and > are escaped so html tags are not rendered * @param input */ function mdclean(input) { if (typeof input !== 'string') { return `${input}`; } return input .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/\|/g, '\\|') .replace(/\r?\n/g, '<br/>'); } exports.mdclean = mdclean; const readdirSync = (0, lodash_memoize_1.default)(fs_1.default.readdirSync); /** * Find a file in a directory, case-insensitive * * @param {string} filepath * @return {string|undefined} File path with correct case */ function findFileCaseInsensitive(filepath) { const dir = path_1.default.dirname(filepath); const fileNameLower = path_1.default.basename(filepath).toLowerCase(); const files = readdirSync(dir); const found = files.find((file) => file.toLowerCase() === fileNameLower); return found && path_1.default.join(dir, found); } exports.findFileCaseInsensitive = findFileCaseInsensitive; /** * Clear cache. */ function clearCache() { const sync = readdirSync.cache; sync.clear(); } exports.clearCache = clearCache; //# sourceMappingURL=utils.js.map