UNPKG

@adocasts.com/jumpstart

Version:

Jumpstart your next AdonisJS 6 web project with authentication, forgot password, and more features out-of-the-box.

17 lines (16 loc) 414 B
import { readFile } from 'node:fs/promises'; export async function readFileOrDefault(filePath, defaultValue) { try { const data = await readFile(filePath, 'utf8'); return data; } catch (err) { if (err.code === 'ENOENT') { return defaultValue; } else { console.error(`Error reading file: ${err}`); throw err; } } }