2022-02-14 10:54:25 +07:00
|
|
|
import * as fs from "fs"
|
|
|
|
import * as path from "path"
|
|
|
|
import { DEFAULT_ENCODING_TYPE } from "../config"
|
|
|
|
|
2022-02-14 12:30:32 +07:00
|
|
|
export const readFileToStringDefaultEncoding = (
|
2022-02-14 10:54:25 +07:00
|
|
|
relativeFilePath: string
|
|
|
|
): string => {
|
|
|
|
const absolutePath = path.resolve(relativeFilePath)
|
|
|
|
return fs.readFileSync(absolutePath, DEFAULT_ENCODING_TYPE)
|
|
|
|
}
|
2022-02-14 12:30:32 +07:00
|
|
|
|
|
|
|
export const readFileToJson = (relativeFilePath: string): any => {
|
|
|
|
return JSON.parse(readFileToStringDefaultEncoding(relativeFilePath))
|
|
|
|
}
|