doRun method

  1. @override
Future<int> doRun()
override

Implementation

@override
Future<int> doRun() async {
  const fs = IOFileSystem();

  final pubspecExists = await Spec.exists(fs);
  if (!pubspecExists) {
    return error(1,
        message: 'You should run command from project root directory.');
  }

  final issueUrl = config.issueUrl;
  if (issueUrl == null) {
    return error(1,
        message: 'issue_url is not set in alex config. '
            'Add `issue_url: <base url>` to alex.yaml or to the alex section '
            'of pubspec.yaml.');
  }

  final changelog = Changelog(fs);
  if (!(await changelog.exists)) {
    return error(1, message: 'CHANGELOG.md is not found.');
  }

  final count = await changelog.linkIssueReferences(issueUrl);
  if (count == 0) {
    return success(message: 'No plain issue references to update.');
  }

  await changelog.save();
  return success(message: 'Updated $count issue reference(s).');
}