fix: skip root check for renderFile()

This commit is contained in:
Harttle
2021-10-06 18:38:58 +08:00
parent a3455ebd0b
commit 822ba0be0f
9 changed files with 31 additions and 24 deletions
+7 -2
View File
@@ -5,8 +5,13 @@ import { stat, statSync, readFile as nodeReadFile, readFileSync as nodeReadFileS
const statAsync = _.promisify(stat)
const readFileAsync = _.promisify<string, string, string>(nodeReadFile)
export function exists (filepath: string) {
return statAsync(filepath).then(() => true).catch(() => false)
export async function exists (filepath: string) {
try {
await statAsync(filepath)
return true
} catch (err) {
return false
}
}
export function readFile (filepath: string) {
return readFileAsync(filepath, 'utf8')