All files / src docs-board-sync.ts

55.76% Statements 29/52
72.72% Branches 16/22
75% Functions 12/16
55.76% Lines 29/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 531x 1x 1x 1x 1x 6x 6x 1x 1x 4x 4x 4x 1x 1x 2x 2x 2x 2x 2x 1x 1x 2x     2x 2x 2x 1x 1x                 1x 1x                            
import * as path from "node:path"
 
import type * as vscode from "vscode"
 
export function meridianDbPath(packageRoot: string): string {
  return path.join(packageRoot, ".meridian", "meridian.db")
}
 
export function isMeridianDbPath(packageRoot: string, filePath: string): boolean {
  const db = path.resolve(meridianDbPath(packageRoot))
  return path.resolve(filePath) === db
}
 
export function fileEventTouchesMeridianDb(
  packageRoot: string,
  files: readonly { readonly oldUri?: vscode.Uri; readonly newUri?: vscode.Uri }[],
): boolean {
  for (const entry of files) {
    if (entry.newUri && isMeridianDbPath(packageRoot, entry.newUri.fsPath)) {
      return true
    }
    if (entry.oldUri && isMeridianDbPath(packageRoot, entry.oldUri.fsPath)) {
      return true
    }
  }
  return false
}
 
export function isArchitectureDiagramPath(docsRoot: string, filePath: string): boolean {
  const diagramsDir = path.join(docsRoot, "architecture", "diagrams")
  const resolved = path.resolve(filePath)
  if (!resolved.startsWith(path.resolve(diagramsDir) + path.sep)) {
    return false
  }
  const ext = path.extname(resolved).toLowerCase()
  return ext === ".md" || ext === ".mmd"
}
 
export function fileEventTouchesArchitectureDiagrams(
  docsRoot: string,
  files: readonly { readonly oldUri?: vscode.Uri; readonly newUri?: vscode.Uri }[],
): boolean {
  for (const entry of files) {
    if (entry.newUri && isArchitectureDiagramPath(docsRoot, entry.newUri.fsPath)) {
      return true
    }
    if (entry.oldUri && isArchitectureDiagramPath(docsRoot, entry.oldUri.fsPath)) {
      return true
    }
  }
  return false
}