JoshuaKGoldberg / JoshuaKGoldberg/formatly
🚀 Feature: Importable API to format file(s) in memory
- Dominant language
- TypeScript
- Stars
- 47
- Forks
- 3
- Avg merge
- 34m
- Merged PRs (30d)
- 38
Description
### Bug Report Checklist
- [X] I have pulled the latest `main` branch of the repository.
- [X] I have [searched for related issues](https://github.com/JoshuaKGoldberg/formatly/issues?q=is%3Aissue) and found none that matched my issue.
### Overview
Right now, the exported `formatly` API is effectively a CLI runner. It runs shell scripts with `execa`. But in theory users would alternately want an API that formats a file in memory. Like:
```ts
import { format } from "formatly";
const formatted = await format("console.log(123);", { filename: "index.ts" });
await fs.writeFile(formatted, "index.ts");
```
Accepting PRs to make that `format` API.
### Additional Info
Implementing this is likely tricky. Deno APIs aren't available in Node.js, so if the user is on a Deno project then running formatly from Node won't work. Implementer beware: this is not an easy issue.
💖
Contributor guide
Assessment
This issue has not been assessed yet.