// llm-detector/file-readers.ts — File reading utilities for LLM detection
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
export async function readFileOrNull(filePath) {
    try {
        return await readFile(filePath, 'utf-8');
    }
    catch {
        return null;
    }
}
export async function readPackageJson(projectPath) {
    const content = await readFileOrNull(join(projectPath, 'package.json'));
    if (!content) {
        return null;
    }
    try {
        const pkg = JSON.parse(content);
        return { deps: pkg.dependencies ?? {}, devDeps: pkg.devDependencies ?? {} };
    }
    catch {
        /* v8 ignore next 1 */
        return null;
    }
}
export async function readPythonDeps(projectPath) {
    const req = await readFileOrNull(join(projectPath, 'requirements.txt'));
    if (req) {
        return req;
    }
    return readFileOrNull(join(projectPath, 'pyproject.toml'));
}
//# sourceMappingURL=file-readers.js.map