oneuptime/CommonServer/Utils/LocalFile.ts

21 lines
596 B
TypeScript
Raw Normal View History

2023-03-18 21:37:34 +00:00
import fs from 'fs';
export default class LocalFile {
public static async read(path: string): Promise<string> {
2023-03-18 21:48:21 +00:00
return new Promise(
(resolve: (data: string) => void, reject: Function) => {
2023-03-20 18:06:50 +00:00
fs.readFile(
2023-03-18 21:48:21 +00:00
path,
{ encoding: 'utf-8' },
(err: unknown, data: string) => {
if (!err) {
return resolve(data);
}
return reject(err);
}
);
}
);
2023-03-18 21:37:34 +00:00
}
2023-03-18 21:48:21 +00:00
}