UNPKG

vuoto

Version:

Modern whitespace normalizer CLI with enhanced output and developer experience - cut the noise, clean the void

28 lines (27 loc) 711 B
import fsp from 'node:fs/promises'; import path from 'node:path'; /** * Read .gitignore file in a directory, if present. * @param dir The directory to read the .gitignore file from. * * @returns The patterns from the .gitignore file. * * @example * * ```ts * const patterns = await readGitignoreFile(process.cwd()); * ``` */ export async function readGitignoreFile(dir) { const gitignorePath = path.join(dir, '.gitignore'); try { const content = await fsp.readFile(gitignorePath, 'utf8'); return content .split('\n') .map((line) => line.trim()) .filter((line) => line && !line.startsWith('#')); } catch { return []; } }