checkPackage method
checks with the user that we are operating on the correct package and returns details of the packages pubspec.yaml.
Als prints the version of the package we found.
If autoAnswer
is false we don't ask the user to confirm the package.
Implementation
PubSpecDetails checkPackage({required bool autoAnswer}) {
final pubspecPath = findPubSpec(startingDir: pathToPackageRoot);
if (pubspecPath == null) {
print('Unable to find pubspec.yaml, run ${DartScript.self.exeName} '
'from the main '
"package's root directory.");
exit(1);
}
final pubspec = PubSpec.fromFile(pubspecPath);
pubspec.version = pubspec.version ?? Version.parse('0.0.1');
print('');
print(green('Found ${pubspec.name} version ${pubspec.version}'));
print('');
return PubSpecDetails(pubspec, pubspecPath);
}