Skip to content

Commit aaf522b

Browse files
bparrishMinesadsonpleal
authored andcommitted
Publish check ignores prerelease sdk (flutter#3560)
1 parent 9bb0949 commit aaf522b

File tree

1 file changed

+40
-7
lines changed

1 file changed

+40
-7
lines changed

script/tool/lib/src/publish_check_command.dart

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:io' as io;
67

78
import 'package:colorize/colorize.dart';
89
import 'package:file/file.dart';
@@ -63,6 +64,44 @@ class PublishCheckCommand extends PluginCommand {
6364
}
6465
}
6566

67+
Future<bool> hasValidPublishCheckRun(Directory package) async {
68+
final io.Process process = await io.Process.start(
69+
'flutter',
70+
<String>['pub', 'publish', '--', '--dry-run'],
71+
workingDirectory: package.path,
72+
);
73+
74+
final StringBuffer outputBuffer = StringBuffer();
75+
76+
final Completer<void> stdOutCompleter = Completer<void>();
77+
process.stdout.listen(
78+
(List<int> event) {
79+
io.stdout.add(event);
80+
outputBuffer.write(String.fromCharCodes(event));
81+
},
82+
onDone: () => stdOutCompleter.complete(),
83+
);
84+
85+
final Completer<void> stdInCompleter = Completer<void>();
86+
process.stderr.listen(
87+
(List<int> event) {
88+
io.stderr.add(event);
89+
outputBuffer.write(String.fromCharCodes(event));
90+
},
91+
onDone: () => stdInCompleter.complete(),
92+
);
93+
94+
if (await process.exitCode == 0) return true;
95+
96+
await stdOutCompleter.future;
97+
await stdInCompleter.future;
98+
99+
final String output = outputBuffer.toString();
100+
return output.contains('Package has 1 warning.') &&
101+
output.contains(
102+
'Packages with an SDK constraint on a pre-release of the Dart SDK should themselves be published as a pre-release version.');
103+
}
104+
66105
Future<bool> passesPublishCheck(Directory package) async {
67106
final String packageName = package.basename;
68107
print('Checking that $packageName can be published.');
@@ -75,13 +114,7 @@ class PublishCheckCommand extends PluginCommand {
75114
return true;
76115
}
77116

78-
final int exitCode = await processRunner.runAndStream(
79-
'flutter',
80-
<String>['pub', 'publish', '--', '--dry-run'],
81-
workingDir: package,
82-
);
83-
84-
if (exitCode == 0) {
117+
if (await hasValidPublishCheckRun(package)) {
85118
print("Package $packageName is able to be published.");
86119
return true;
87120
} else {

0 commit comments

Comments
 (0)