astro-ghostcms/.pnpm-store/v3/files/03/fab5ee4f91d82bc27eb8e6b3645...

17 lines
454 B
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
import fs from 'graceful-fs'
export function readCAFileSync (filePath: string): string[] | undefined {
try {
const contents = fs.readFileSync(filePath, 'utf8')
const delim = '-----END CERTIFICATE-----'
const output = contents
.split(delim)
.filter((ca) => Boolean(ca.trim()))
.map((ca) => `${ca.trimLeft()}${delim}`)
return output
} catch (err) {
if (err.code === 'ENOENT') return undefined
throw err
}
}