standardlint
Version:
Extensible standards linter and auditor.
42 lines (39 loc) • 1.2 kB
JavaScript
import {
readDirectory
} from "./chunk-LE2L7JFB.mjs";
import {
logDefaultPathMessage
} from "./chunk-322CAOWI.mjs";
import {
exists
} from "./chunk-DRBJPZVI.mjs";
import {
calculatePass
} from "./chunk-I4KWICZI.mjs";
// src/checks/checkForPresenceDiagramsFolder.ts
function checkForPresenceDiagramsFolder(severity, basePath, customPath, filetreePaths) {
const path = customPath || "diagrams";
const name = "Diagrams";
const message = "Check for diagrams folder with contents";
if (!customPath) logDefaultPathMessage(name, path);
const result = (() => {
const diagramsPath = `${basePath}/${path}`;
if (filetreePaths && filetreePaths.length > 0)
return hasDiagramMatches(filetreePaths, diagramsPath.replace("./", ""));
if (exists(diagramsPath, ""))
return hasDiagramMatches(readDirectory(diagramsPath));
return false;
})();
return {
name,
status: calculatePass(result, severity),
message,
path
};
}
var hasDiagramMatches = (contents, startPath = "") => contents.map(
(fileName) => fileName.startsWith(startPath) && fileName.endsWith(".drawio")
).filter((match) => match).length > 0;
export {
checkForPresenceDiagramsFolder
};