mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
feat(infra): route package (#10353)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user