Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-coats-stick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bomb.sh/tools": patch
---

`format` CLI command respects internal format call and passes the exit code to the user.
5 changes: 3 additions & 2 deletions src/commands/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { local } from '../utils.ts';
const config = fileURLToPath(new URL('../../oxfmtrc.json', import.meta.url));

export async function format(ctx: CommandContext) {
const stdio = x(local('oxfmt'), ['-c', config, ...ctx.args]);
const result = x(local('oxfmt'), ['-c', config, ...ctx.args]);

for await (const line of stdio) {
for await (const line of result) {
console.info(line);
}
if (result.exitCode !== 0) process.exit(result.exitCode!);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

Suggested change
if (result.exitCode !== 0) process.exit(result.exitCode!);
if (result.exitCode) process.exit(result.exitCode);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but it didn't feel appropriate to always call process.exit(). Don't love calling it either way, but kind of following precedenc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestions just removes non-null assertion, if result.exitCode is falsy, it still skips

}
Loading