@hyperse/dependency-sync
Version:
A comprehensive Node.js utility for managing dependencies in monorepo environments, specifically designed for Hyperse plugin ecosystems.
15 lines (14 loc) • 408 B
JavaScript
import { readFileSync } from 'node:fs';
/**
* Read a JSON file and return the parsed object.
* @example
* ```ts
* const json = readJson<{ name: string }>('package.json');
* ```
* @param fileFrom - The path to the JSON file.
* @returns The parsed JSON object.
*/
export function readJson(fileFrom) {
const content = readFileSync(fileFrom, { encoding: 'utf-8' });
return JSON.parse(content);
}