test-reporter/src/utils/file-utils.ts
2020-11-17 22:21:16 +01:00

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'})
}