< Summary - Envilder CLI

Information
Class: src/envilder/core/application/execWithSecrets/CommandLineFormatter.ts
Assembly: Default
File(s): src/envilder/core/application/execWithSecrets/CommandLineFormatter.ts
Tag: 561_41292037308
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 23
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/application/execWithSecrets/CommandLineFormatter.ts

#LineLine coverage
 81const SAFE_ARGUMENT = /^[\w@%+=:,./-]+$/;
 2
 3/**
 4 * Renders one token for display on a single line. Tokens with spaces,
 5 * quotes, shell metacharacters or control characters are shown JSON-quoted,
 6 * which reads the same on every platform and never spans lines.
 7 */
 8export function formatArgument(argument: string): string {
 669  return SAFE_ARGUMENT.test(argument) ? argument : JSON.stringify(argument);
 10}
 11
 12/**
 13 * Renders a command for Envilder's own output: the program name only,
 14 * followed by an ellipsis when it has arguments. Arguments are never shown
 15 * because they can carry secrets (for example an `Authorization` header).
 16 */
 17export function formatProgram(
 18  command: string,
 19  args: readonly unknown[],
 20): string {
 5921  const program = formatArgument(command);
 5922  return args.length > 0 ? `${program} \u2026` : program;
 23}

Methods/Properties

formatArgument
formatProgram