mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 01:16:53 +00:00
Co-authored-by: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Co-authored-by: jacob <jacoobes@sern.dev>
19 lines
588 B
TypeScript
19 lines
588 B
TypeScript
import { findUp } from 'find-up';
|
|
import { readFile } from 'node:fs/promises';
|
|
|
|
/**
|
|
* It finds the sern.config.json file, reads it, and returns the language property
|
|
* @returns The language of the project.
|
|
*/
|
|
export async function getLang(): Promise<'typescript' | 'javascript'> {
|
|
const sernLocation = await findUp('sern.config.json');
|
|
|
|
if (!sernLocation) throw new Error("Can't find sern.config.json");
|
|
|
|
const output = JSON.parse(await readFile(sernLocation, 'utf8'));
|
|
|
|
if (!output) throw new Error("Can't read your sern.config.json.");
|
|
|
|
return output.language;
|
|
}
|