Skip to content

Commit

Permalink
Fix makeFormatToRule
Browse files Browse the repository at this point in the history
The existing rule writes an empty file as `biome format` will only
output the resulting formatted file when using `--stdin-file-path`.
  • Loading branch information
elliotgoodrich committed Mar 6, 2024
1 parent ddf5086 commit f94e8e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/biome/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ninjutsu-build/biome",
"version": "0.7.3",
"version": "0.7.4",
"description": "A biome plugin for ninjutsu-build",
"author": "Elliot Goodrich",
"scripts": {
Expand Down
11 changes: 7 additions & 4 deletions packages/biome/src/biome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { platform, arch } from "os";

const exe = platform() === "win32" ? ".exe" : "";
const prefix = platform() === "win32" ? "cmd /c " : "";
const cat = platform() === "win32" ? "type" : "cat";

// Don't use `npx biome format` as this requires a node process and
// the overhead is so much greater than running the biome executable.
Expand Down Expand Up @@ -180,8 +181,8 @@ export function makeFormatToRule(
ninja: NinjaBuilder,
name = "formatTo",
): <O extends string>(args: {
in: Input<string>;
out: O;
in: Input<string>;
configPath: string;
args?: string;
[implicitDeps]?: string | readonly string[];
Expand All @@ -192,17 +193,19 @@ export function makeFormatToRule(
const formatTo = ninja.rule(name, {
command:
prefix +
cat +
" $in | " +
join("node_modules", biomeCommand) +
" format $args --config-path $configPath > $out",
description: "Creating formatted $out",
" format $args --config-path $configPath --stdin-file-path=$in > $out",
description: "Formatting $in to $out",
in: needs<Input<string>>(),
out: needs<string>(),
configPath: needs<string>(),
args: "",
});
return <O extends string>(a: {
in: Input<string>;
out: O;
in: Input<string>;
configPath: string;
args?: string;
[implicitDeps]?: string | readonly string[];
Expand Down

0 comments on commit f94e8e9

Please sign in to comment.