publish method

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

Implementation

void 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) {
    cmd += ' --force';
  }
  cmd.start(workingDirectory: projectRoot, terminal: true, nothrow: true);
}