Skip to content

Commit

Permalink
Format file
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 22, 2024
1 parent b90307b commit ca8d847
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 4 additions & 1 deletion examples/format-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import makeSynchronized from "make-synchronized";
export default makeSynchronized(import.meta, async function formatFile(file) {
const config = await prettier.resolveConfig(file);
const content = await fs.readFile(file, "utf8");
const formatted = await prettier.format(content, {...config,filepath: file});
const formatted = await prettier.format(content, {
...config,
filepath: file,
});
await fs.writeFile(file, formatted);
});
9 changes: 3 additions & 6 deletions examples/run-format-file.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import * as url from "node:url";
import formatFile from './format-file.js'
import formatFile from "./format-file.js";

console.log(
formatFile(
url.fileURLToPath(new URL('../readme.md', import.meta.url))

)
)
formatFile(url.fileURLToPath(new URL("../readme.md", import.meta.url))),
);

0 comments on commit ca8d847

Please sign in to comment.