All files plainstack-fs.ts

62.5% Statements 15/24
80% Branches 4/5
66.66% Functions 2/3
62.5% Lines 15/24

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 281x   23x 23x 23x 18x 23x 5x 5x 23x   10x 10x 10x 10x 10x     10x                  
import fs from "node:fs/promises";
 
export async function fileExists(filePath: string) {
  try {
    await fs.access(filePath);
    return true;
  } catch {
    return false;
  }
}
 
export async function directoryExists(dirPath: string) {
  try {
    await fs.access(dirPath);
    return true;
  } catch {
    return false;
  }
}
 
export async function ensureDirectoryExists(dirPath: string): Promise<void> {
  try {
    await fs.access(dirPath);
  } catch {
    await fs.mkdir(dirPath, { recursive: true });
  }
}