publish method

bool publish(
  1. String pubspecPath, {
  2. required bool autoAnswer,
  3. required bool dryrun,
})

Implementation

bool publish(String pubspecPath,
    {required bool autoAnswer, required bool dryrun}) {
  final projectRoot = dirname(pubspecPath);

  final version = Version.parse(Platform.version.split(' ')[0]);
  var cmd = 'dart pub publish';
  if (version.major == 2 && version.minor < 9) {
    cmd = 'pub publish';
  }

  if (dryrun) {
    cmd += ' --dry-run';
  }
  if (autoAnswer && !dryrun) {
    cmd += ' --force';
  }

  // if (!waitForEx(cli.check(cmd, workingDirectory: projectRoot))) {
  //   throw PubReleaseException('The publish attempt failed.');
  // }

  final progress = cmd.start(
      terminal: true,
      workingDirectory: projectRoot,
      progress: Progress.print(),
      nothrow: true);

  return progress.exitCode == 0;
}