mirror of
https://github.com/dorny/test-reporter.git
synced 2026-06-09 09:17:09 +00:00
13 lines
307 B
TypeScript
13 lines
307 B
TypeScript
import * as fs from 'fs'
|
|
|
|
export function getFileContent(path: string): string {
|
|
if (!fs.existsSync(path)) {
|
|
throw new Error(`File '${path}' not found`)
|
|
}
|
|
|
|
if (!fs.lstatSync(path).isFile()) {
|
|
throw new Error(`'${path}' is not a file`)
|
|
}
|
|
|
|
return fs.readFileSync(path, {encoding: 'utf8'})
|
|
}
|