dcliExit function

void dcliExit(
  1. int exitCode
)

Use this method rather than dart:io.exit() as it is unit test friendly in that it will throw an ExitException to avoid shutting the entire unit test framework down.

Implementation

void dcliExit(int exitCode) {
  if (Scope.use(unitTestingKey)) {
    // If we allow the call to io.exit to proceed
    // then the unit test framework would shutdown.
    // so instead we throw an exception.
    throw ExitException(exitCode);
  }

  // so we are not in a unit test, so we can just shutdown
  io.exit(exitCode);
}