Skip to content

Commit c231ec6

Browse files
committed
fix: update lib
1 parent a46dd51 commit c231ec6

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/lib/boolean.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ export function storageExists(): boolean {
2323
return false
2424
}
2525
}
26+
27+
/**
28+
* Check if mail is enabled
29+
*/
30+
export function mailExists(): boolean {
31+
return Boolean(
32+
env.MAIL_HOST && env.MAIL_PORT && env.MAIL_USERNAME && env.MAIL_PASSWORD && env.MAIL_FROM
33+
)
34+
}

src/lib/fs/read-file.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { green } from 'colorette'
2+
import fs from 'fs'
3+
import * as fsAsync from 'fs/promises'
4+
import { logger } from '~/config/logger'
5+
6+
const msgType = `${green('filesystem')}`
7+
8+
/**
9+
* Read HTML file
10+
* @param filePath - path to HTML file
11+
* @returns HTML file content
12+
*/
13+
export async function readHTMLFile(
14+
filePath: fs.PathLike | fs.promises.FileHandle
15+
): Promise<string> {
16+
try {
17+
return await fsAsync.readFile(filePath, 'utf-8')
18+
} catch (err) {
19+
logger.error(`${msgType} - invalid HTML file path: ${filePath}`)
20+
throw new Error(`invalid HTML file path: ${filePath}`)
21+
}
22+
}

0 commit comments

Comments
 (0)