execute method

  1. @override
bool execute(
  1. ReleasePacker releasePacker,
  2. Directory rootDirectory, {
  3. ReleaseBundle? releaseBundle,
  4. int expectedExitCode = 0,
})
override

Implementation

@override
bool execute(ReleasePacker releasePacker, Directory rootDirectory,
    {ReleaseBundle? releaseBundle, int expectedExitCode = 0}) {
  String commandPath;
  if (!containsGenericPathSeparator(command)) {
    commandPath = whichExecutablePath(command);
  } else {
    commandPath = command;
  }

  var fullCommandPath = joinPaths(rootDirectory.path, commandPath);

  print(
      '   »  Process command> ${rootDirectory.path} -> $fullCommandPath $args');

  var result = Process.runSync(fullCommandPath, args,
      workingDirectory: rootDirectory.path);

  saveStdout(rootDirectory, result.stdout);
  saveStderr(rootDirectory, result.stderr);

  var exitCode = result.exitCode;
  var ok = exitCode == expectedExitCode;

  if (!ok) {
    print(
        '  ▒  Command error! exitCode: $exitCode ; command: $command $args');
    print(result.stdout);
    print(result.stderr);
  }

  return ok;
}