mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add getJsonDirectory helper
This commit is contained in:
parent
7be3c23efb
commit
f1750ef4aa
2 changed files with 30 additions and 1 deletions
23
helpers/get-json-directory.js
Normal file
23
helpers/get-json-directory.js
Normal 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' )
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue