Skip to content

Commit beaf3a9

Browse files
authored
Fix json mode (#124)
* fix(contracts): output well formed json from --json flag * feat(cli): if json flag is specified do not display app banner or nudge users to upgrade
1 parent 12a1363 commit beaf3a9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import { registerVM } from "./lib/vm.ts";
2626

2727
const program = new Command();
2828

29-
await Promise.all([checkVersion(), getAppBanner()]);
29+
if (!process.argv.includes("--json")) {
30+
await Promise.all([checkVersion(), getAppBanner()]);
31+
}
3032

3133
program
3234
.name("sf")

src/lib/contracts/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export function registerContracts(program: Command) {
4747
)
4848
.description("List all contracts")
4949
.action(async (options) => {
50+
const contracts = await listContracts(options.all, options.state);
5051
if (options.json) {
51-
console.log(await listContracts(options.all, options.state));
52+
console.log(JSON.stringify(contracts, null, 2));
5253
} else {
53-
const data = await listContracts(options.all, options.state);
54-
render(<ContractList contracts={data} />);
54+
render(<ContractList contracts={contracts} />);
5555
}
5656
}),
5757
);

0 commit comments

Comments
 (0)