Add getJsonDirectory helper

This commit is contained in:
Sam Carlton 2021-09-18 14:23:34 -05:00
parent 7be3c23efb
commit f1750ef4aa
2 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,23 @@
import fs from 'fs-extra'
const directoriesToTry = [
'./static/',
// Vercel Serverless Function
'./.next/server/chunks/static'
]
export async function getJsonDirectory () {
for ( const directory of directoriesToTry ) {
const directoryExists = await fs.pathExists( directory )
if ( directoryExists ) {
return directory
}
}
throw new Error( 'Could not find json directory' )
}