UNPKG

@eve-tools/cli

Version:

Everest cli to speed up project start-up and standardized frontend , backend architecture

24 lines (23 loc) 899 B
import { readFile } from "node:fs/promises"; import path from "path"; import { spinner } from "../../utils/spinner.js"; import { tryCatchWrapper } from "../../utils/try-catch-wrapper.js"; export const CheckPackageJson = async (cwd) => { let absolutePkgJsonPath = ""; let pkgJson = {}; const { start, succeed, fail } = spinner("Checking dependencies 🧐"); await tryCatchWrapper(async () => { start(); absolutePkgJsonPath = path.resolve(cwd, "package.json"); const pkgData = await readFile(absolutePkgJsonPath, "utf-8"); if (!pkgData) { fail("package.json not found 🤷‍♂️"); throw new Error("package.json not found."); } pkgJson = JSON.parse(pkgData); succeed("Checking Succeed 🎉"); }, () => { fail("Checking Failed 😞"); }); return { absolutePkgJsonPath, pkgJson }; };