< Summary - Envilder CLI

Information
Class: src/envilder/core/domain/ExecExitCode.ts
Assembly: Default
File(s): src/envilder/core/domain/ExecExitCode.ts
Tag: 561_41292037308
Line coverage
90%
Covered lines: 9
Uncovered lines: 1
Coverable lines: 10
Total lines: 29
Line coverage: 90%
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/domain/ExecExitCode.ts

#LineLine coverage
 1import type { ProcessExit } from './ports/IProcessRunner.js';
 2
 3/**
 4 * Exit codes used by exec mode. They follow GNU `env` and `docker run`, so a
 5 * caller can tell an Envilder failure apart from the child's own exit code.
 6 */
 97export const EXEC_ENVILDER_FAILURE = 125;
 98export const EXEC_COMMAND_NOT_EXECUTABLE = 126;
 99export const EXEC_COMMAND_NOT_FOUND = 127;
 10
 911const SIGNAL_EXIT_BASE = 128;
 912const UNKNOWN_CHILD_FAILURE = 1;
 13
 14/**
 15 * Translates how the child ended into the exit code Envilder must return:
 16 * the child's own code, or `128 + n` when it was killed by signal `n`.
 17 */
 18export function exitCodeForChild(
 19  exit: ProcessExit,
 20  signalNumber: (signal: NodeJS.Signals) => number,
 21): number {
 5322  if (exit.code !== null) {
 4623    return exit.code;
 24  }
 725  if (exit.signal !== null) {
 726    return SIGNAL_EXIT_BASE + signalNumber(exit.signal);
 27  }
 028  return UNKNOWN_CHILD_FAILURE;
 29}

Methods/Properties

exitCodeForChild