pr-check / src / filesystem / readFile.ts
readFile.ts
Raw
import fs from 'fs'
import { doesFileExist } from './doesFileExist';

function readFile(filePath: string) {
  // Check if the file exists
  if (!doesFileExist(filePath)) {
    throw new Error('File not found');
  }
  
  // Read the file and return its content as a string
  const fileContent = fs.readFileSync(filePath, 'utf8');
  return fileContent;
}

export { readFile }