UNPKG

mdxlayer

Version:

Transform your MDX content into typed, JSON-powered data with flexible schema validation.

25 lines (23 loc) 665 B
const cliArgs = process.argv.slice(2); const hasCliFlag = (flags) => { if (typeof flags === "string") { return cliArgs.includes(flags); } return flags.some((flag) => cliArgs.includes(flag)); }; const cliConfigFile = (() => { if (hasCliFlag("--config")) { const maybeConfig = cliArgs[cliArgs.indexOf("--config") + 1]; return maybeConfig ?? null; } return null; })(); const cliOutDir = (() => { const defaultOutDir = ".mdxlayer"; if (hasCliFlag("--out")) { const maybeOut = cliArgs[cliArgs.indexOf("--out") + 1]; return maybeOut ?? defaultOutDir; } return defaultOutDir; })(); export { cliConfigFile, cliOutDir, hasCliFlag };