remove an extra period from a publish message (#3812)
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart index bc080db..8e16ca6 100644 --- a/lib/src/command/lish.dart +++ b/lib/src/command/lish.dart
@@ -320,10 +320,11 @@ if (force) return true; String formatWarningCount() { - final hs = hints.length == 1 ? '' : 's'; - final hintText = hints.isEmpty ? '' : ' and ${hints.length} hint$hs.'; - final ws = warnings.length == 1 ? '' : 's'; - return '\nPackage has ${warnings.length} warning$ws$hintText.'; + final hintText = hints.isEmpty + ? '' + : ' and ${hints.length} ${pluralize('hint', hints.length)}'; + return '\nPackage has ${warnings.length} ' + '${pluralize('warning', warnings.length)}$hintText.'; } if (dryRun) {
diff --git a/lib/src/command/upgrade.dart b/lib/src/command/upgrade.dart index 8957e5b..17db3e7 100644 --- a/lib/src/command/upgrade.dart +++ b/lib/src/command/upgrade.dart
@@ -324,10 +324,9 @@ final wouldBe = _dryRun ? 'would be made to' : 'to'; log.message('\nNo changes $wouldBe pubspec.yaml!'); } else { - final s = changes.length == 1 ? '' : 's'; - final changed = _dryRun ? 'Would change' : 'Changed'; - log.message('\n$changed ${changes.length} constraint$s in pubspec.yaml:'); + log.message('\n$changed ${changes.length} ' + '${pluralize('constraint', changes.length)} in pubspec.yaml:'); changes.forEach((from, to) { log.message(' ${from.name}: ${from.constraint} -> ${to.constraint}'); });
diff --git a/lib/src/utils.dart b/lib/src/utils.dart index b339fc9..061bd7c 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart
@@ -206,8 +206,7 @@ /// [plural] is passed, that's used instead. String pluralize(String name, int number, {String? plural}) { if (number == 1) return name; - if (plural != null) return plural; - return '${name}s'; + return plural ?? '${name}s'; } /// Returns [text] with the first letter capitalized.