UNPKG

@nuxtjs/prismic

Version:

Easily connect your Nuxt application to your content hosted on Prismic

16 lines (12 loc) 394 B
import { existsSync } from 'node:fs' export const fileExists = (path?: string, extensions = ['js', 'ts']): string | null => { if (!path) { return null } else if (existsSync(path)) { // If path already contains/forces the extension return path } const extension = extensions.find(extension => existsSync(`${path}.${extension}`)) return extension ? `${path}.${extension}` : null }