UNPKG

@mintlify/prebuild

Version:

Helpful functions for Mintlify's prebuild step

20 lines (19 loc) 728 B
import fse from 'fs-extra'; import pathUtil from 'path'; export const getFileExtension = (filename) => { const parsed = pathUtil.parse(filename); return parsed.ext ? parsed.ext.slice(1) : filename; }; export const getConfigPath = async (contentDirectoryPath, type) => { const path = pathUtil.join(contentDirectoryPath, `${type}.json`); if (!(await fse.pathExists(path))) return null; return path; }; export const getConfigObj = async (contentDirectoryPath, type) => { const configPath = await getConfigPath(contentDirectoryPath, type); if (!configPath) return null; const configContents = await fse.readFile(configPath); return await JSON.parse(configContents.toString()); };