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
4 changes: 3 additions & 1 deletion src/commands/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export function registerJobCommands(program: Command): void {
);
for (const j of allJobs) {
const budget = !j.legacy
? formatUnits(BigInt(j.budget), 6)
? j.budget
? formatUnits(BigInt(j.budget), 6)
: "N/A"
: j.budget;
console.log(
`${j.onChainJobId}\t${j.chainId}\t${j.clientAddress}\t${j.providerAddress}\t${budget}\t${j.jobStatus}\t${j.legacy}`
Expand Down
9 changes: 7 additions & 2 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
import { homedir } from "os";
import { resolve } from "path";
import { join, resolve } from "path";
import {
getPassword,
setPassword,
Expand Down Expand Up @@ -59,7 +59,12 @@ function loadConfig(): Config {

function saveConfig(config: Config): void {
mkdirSync(CONFIG_DIR, { recursive: true });
writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
// Write to a temp file first, then atomically rename to the final path.
// This prevents a truncated/partial JSON file if the process is interrupted
// mid-write, which would make loadConfig return an empty object on next run.
const tmpPath = join(CONFIG_DIR, `${CONFIG_FILENAME}.tmp`);
writeFileSync(tmpPath, JSON.stringify(config, null, 2) + "\n");
renameSync(tmpPath, CONFIG_PATH);
}

function isKeychainUnavailable(err: unknown): boolean {
Expand Down