Download internal/node-utils/src/prettier.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 554 Bytes
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/prettier.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/internal/node-utils/src/prettier.ts
-
curl -L -o prettier.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/prettier.ts
554 Bytes
| import fs from 'node:fs/promises'; | |
| import { format, getFileInfo, resolveConfig } from 'prettier'; | |
| async function prettierFormat(filepath: string) { | |
| const prettierOptions = await resolveConfig(filepath, {}); | |
| const fileInfo = await getFileInfo(filepath); | |
| const input = await fs.readFile(filepath, 'utf8'); | |
| const output = await format(input, { | |
| ...prettierOptions, | |
| parser: fileInfo.inferredParser as any, | |
| }); | |
| if (output !== input) { | |
| await fs.writeFile(filepath, output, 'utf8'); | |
| } | |
| return output; | |
| } | |
| export { prettierFormat }; | |