UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

26 lines (22 loc) 672 B
/** * @file File content reading utility * @description Single responsibility: Read file contents safely */ const fs = require('fs'); /** * Read file content synchronously * @param {string} filePath - Path to the file * @param {string} encoding - File encoding (default: 'utf8') * @returns {string} File contents */ function readFileContent(filePath, encoding = 'utf8') { if (typeof filePath !== 'string') { throw new TypeError('File path must be a string'); } try { return fs.readFileSync(filePath, encoding); } catch (error) { throw new Error(`Failed to read file ${filePath}: ${error.message}`); } } module.exports = readFileContent;