MCPcopy Create free account
hub / github.com/Snapchat/Valdi / runStep

Function runStep

npm_modules/cli/src/commands/agentCheck.ts:23–47  ·  view source on GitHub ↗
(
  name: string,
  fn: () => Promise<void>,
  json: boolean,
)

Source from the content-addressed store, hash-verified

21}
22
23async function runStep(
24 name: string,
25 fn: () => Promise<void>,
26 json: boolean,
27): Promise<StepResult> {
28 const start = Date.now();
29 if (!json) {
30 console.log(wrapInColor(`▸ ${name}...`, ANSI_COLORS.YELLOW_COLOR));
31 }
32 try {
33 await fn();
34 const durationMs = Date.now() - start;
35 if (!json) {
36 console.log(wrapInColor(` ✓ ${name} (${durationMs}ms)`, ANSI_COLORS.GREEN_COLOR));
37 }
38 return { name, status: 'pass', durationMs };
39 } catch (error) {
40 const durationMs = Date.now() - start;
41 const message = error instanceof Error ? error.message : String(error);
42 if (!json) {
43 console.log(wrapInColor(` ✗ ${name}: ${message}`, ANSI_COLORS.RED_COLOR));
44 }
45 return { name, status: 'fail', durationMs, message };
46 }
47}
48
49async function getModuleTargets(client: BazelClient, module: string): Promise<string[]> {
50 const allTargets = await client.queryTargetsByKindWithFilter('valdi_module', [module], 'pipe');

Callers 1

valdiAgentCheckFunction · 0.85

Calls 5

wrapInColorFunction · 0.90
nowMethod · 0.65
logMethod · 0.65
fnFunction · 0.50
StringClass · 0.50

Tested by

no test coverage detected