Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

493 B
Raw Blame
import { readFileSync } from 'node:fs';

import { once } from 'lodash-es';
import { type BuiltInParserName, format } from 'prettier';

import { ProjectRoot } from './path';

const readConfig = once(() => {
  const path = ProjectRoot.join('.prettierrc').value;
  const config = JSON.parse(readFileSync(path, 'utf-8'));
  return config;
});

export function prettier(content: string, parser: BuiltInParserName) {
  const config = readConfig();
  return format(content, { parser, ...config });
}