From 1403e67144b21cbecb772964441a06897cf33cb2 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 9 Jul 2021 14:58:15 -0700 Subject: [PATCH] Exit the sample index deployment CI script if a sub-process fails (#847) --- web/_tool/build_ci.dart | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/web/_tool/build_ci.dart b/web/_tool/build_ci.dart index d73f0e0c7..29bf7c50b 100644 --- a/web/_tool/build_ci.dart +++ b/web/_tool/build_ci.dart @@ -16,8 +16,8 @@ main() async { ]; print('Building the sample index...'); - await run('samples_index', 'pub', ['get']); - await run('samples_index', 'pub', ['run', 'grinder', 'deploy']); + await _run('samples_index', 'pub', ['get']); + await _run('samples_index', 'pub', ['run', 'grinder', 'deploy']); // Create the directory each Flutter Web sample lives in Directory(p.join(Directory.current.path, 'samples_index', 'public', 'web')) @@ -36,8 +36,17 @@ main() async { 'public', 'web', directoryName); // Build the sample and copy the files - await run(directory, 'flutter', ['pub', 'get']); - await run(directory, 'flutter', ['build', 'web']); - await run(directory, 'mv', [sourceBuildDir, targetDirectory]); + await _run(directory, 'flutter', ['pub', 'get']); + await _run(directory, 'flutter', ['build', 'web']); + await _run(directory, 'mv', [sourceBuildDir, targetDirectory]); + } +} + +// Invokes run() and exits if the sub-process failed. +Future _run( + String workingDir, String commandName, List args) async { + var success = await run(workingDir, commandName, args); + if (!success) { + exit(1); } }