Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 8e06f2c

Browse files
committed
Minor changes to error handling.
Before throwing a `ToolExit`, a error message is printed.
1 parent 9699491 commit 8e06f2c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

script/tool/lib/src/create_all_plugins_app_command.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const String _outputDirectoryFlag = 'output-dir';
1717

1818
const int _exitUpdateMacosPodfileFailed = 3;
1919
const int _exitUpdateMacosPbxprojFailed = 4;
20+
const int _exitGenNativeBuildFilesFailed = 5;
2021

2122
/// A command to create an application that builds all in a single application.
2223
class CreateAllPluginsAppCommand extends PackageCommand {
@@ -66,10 +67,11 @@ class CreateAllPluginsAppCommand extends PackageCommand {
6667

6768
await _genPubspecWithAllPlugins();
6869

69-
/// Run `flutter pub get` to generate all native build files for macOS.
70-
final int genNativeBuildFilesExitCode = await _genNativeBuildFiles();
71-
if (genNativeBuildFilesExitCode != 0) {
72-
throw ToolExit(genNativeBuildFilesExitCode);
70+
/// Run `flutter pub get` to generate all native build files.
71+
final bool didGenNativeBuildFilesSucceed = await _genNativeBuildFiles();
72+
if (!didGenNativeBuildFilesSucceed) {
73+
printError("Failed to generate native build files via 'flutter pub get'");
74+
throw ToolExit(_exitGenNativeBuildFilesFailed);
7375
}
7476

7577
await Future.wait(<Future<void>>[
@@ -272,30 +274,29 @@ dev_dependencies:${_pubspecMapString(pubspec.devDependencies)}
272274
return buffer.toString();
273275
}
274276

275-
Future<int> _genNativeBuildFiles() async {
276-
final io.ProcessResult result = io.Process.runSync(
277+
Future<bool> _genNativeBuildFiles() async {
278+
final int exitCode = await processRunner.runAndStream(
277279
flutterCommand,
278280
<String>[
279281
'pub',
280282
'get',
281283
],
282-
workingDirectory: _appDirectory.path,
284+
workingDir: _appDirectory,
283285
);
284-
285-
print(result.stdout);
286-
print(result.stderr);
287-
return result.exitCode;
286+
return exitCode == 0;
288287
}
289288

290289
Future<void> _updateMacosPodfile() async {
291-
// Only change the macOS deployment target if the host platform is macOS.
290+
/// Only change the macOS deployment target if the host platform is macOS.
291+
/// The Podfile is not generated on other platforms.
292292
if (!io.Platform.isMacOS) {
293293
return;
294294
}
295295

296296
final File podfileFile =
297297
app.platformDirectory(FlutterPlatform.macos).childFile('Podfile');
298298
if (!podfileFile.existsSync()) {
299+
printError("Can't find Podfile for macOS");
299300
throw ToolExit(_exitUpdateMacosPodfileFailed);
300301
}
301302

@@ -317,6 +318,7 @@ dev_dependencies:${_pubspecMapString(pubspec.devDependencies)}
317318
.childDirectory('Runner.xcodeproj')
318319
.childFile('project.pbxproj');
319320
if (!pbxprojFile.existsSync()) {
321+
printError("Can't find project.pbxproj for macOS");
320322
throw ToolExit(_exitUpdateMacosPbxprojFailed);
321323
}
322324

0 commit comments

Comments
 (0)