• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dialoguedb / client-nodejs / 26546440990

28 May 2026 12:12AM UTC coverage: 80.205%. First build
26546440990

Pull #78

github

web-flow
Merge 22684c44d into 8461e5412
Pull Request #78: add cli build

797 of 1003 branches covered (79.46%)

Branch coverage included in aggregate %.

0 of 236 new or added lines in 6 files covered. (0.0%)

1002 of 1240 relevant lines covered (80.81%)

38.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cli/shared.ts
NEW
1
import { DialogueDBError } from "../errors";
×
2

NEW
3
export function parseJSON(label: string, raw: string): unknown {
×
NEW
4
  try {
×
NEW
5
    return JSON.parse(raw);
×
6
  } catch (e) {
NEW
7
    const message = e instanceof Error ? e.message : String(e);
×
NEW
8
    throw new Error(`--${label} is not valid JSON: ${message}`);
×
9
  }
10
}
11

NEW
12
export function parseCSV(raw: string): string[] {
×
NEW
13
  return raw
×
14
    .split(",")
NEW
15
    .map((s) => s.trim())
×
NEW
16
    .filter((s) => s.length > 0);
×
17
}
18

NEW
19
export function parseIntStrict(label: string, raw: string): number {
×
NEW
20
  const n = parseInt(raw, 10);
×
NEW
21
  if (Number.isNaN(n)) {
×
NEW
22
    throw new Error(`--${label} must be an integer, got "${raw}"`);
×
23
  }
NEW
24
  return n;
×
25
}
26

NEW
27
export async function readStdin(): Promise<string> {
×
NEW
28
  const chunks: Buffer[] = [];
×
NEW
29
  for await (const chunk of process.stdin) {
×
NEW
30
    chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
×
31
  }
NEW
32
  return Buffer.concat(chunks).toString("utf8");
×
33
}
34

NEW
35
export async function resolveContent(opts: {
×
36
  content?: string;
37
  stdin?: boolean;
38
}): Promise<string> {
NEW
39
  if (opts.stdin) return (await readStdin()).trimEnd();
×
NEW
40
  if (opts.content !== undefined) return opts.content;
×
NEW
41
  throw new Error("Provide --content <text> or --stdin");
×
42
}
43

NEW
44
export function output(value: unknown): void {
×
NEW
45
  process.stdout.write(JSON.stringify(value, null, 2) + "\n");
×
46
}
47

NEW
48
export function withErrorHandler<A extends unknown[]>(
×
49
  fn: (...args: A) => Promise<void>
50
) {
NEW
51
  return async (...args: A): Promise<void> => {
×
NEW
52
    try {
×
NEW
53
      await fn(...args);
×
54
    } catch (e) {
NEW
55
      if (e instanceof DialogueDBError) {
×
NEW
56
        process.stderr.write(
×
57
          JSON.stringify(
58
            {
59
              error: e.message,
60
              code: e.code,
61
              type: e.type,
62
              statusCode: e.statusCode,
63
              requestId: e.requestId,
64
              details: e.details,
65
            },
66
            null,
67
            2
68
          ) + "\n"
69
        );
70
      } else {
NEW
71
        process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
×
72
      }
NEW
73
      process.exit(1);
×
74
    }
75
  };
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc