File tree Expand file tree Collapse file tree 3 files changed +27
-14
lines changed
Expand file tree Collapse file tree 3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,26 @@ class Flutter {
2020 static Future <void > packagesGet ({
2121 String cwd = '.' ,
2222 bool recursive = false ,
23+ void Function ([String ? ]) Function (String message)? progress,
2324 }) async {
2425 await _installPackages (
25- cmd: (cwd) => _Cmd .run (
26- 'flutter' ,
27- ['packages' , 'get' ],
28- workingDirectory: cwd,
29- ),
26+ cmd: (cwd) async {
27+ final installDone = progress? .call (
28+ 'Running "flutter packages get" in $cwd ' ,
29+ );
30+ try {
31+ final result = await _Cmd .run (
32+ 'flutter' ,
33+ ['packages' , 'get' ],
34+ workingDirectory: cwd,
35+ );
36+ return result;
37+ } catch (_) {
38+ rethrow ;
39+ } finally {
40+ installDone? .call ();
41+ }
42+ },
3043 cwd: cwd,
3144 recursive: recursive,
3245 );
@@ -70,6 +83,8 @@ class Flutter {
7083
7184 if (processes.isEmpty) throw PubspecNotFound ();
7285
73- await Future .wait (processes);
86+ for (final process in processes) {
87+ await process;
88+ }
7489 }
7590}
Original file line number Diff line number Diff line change @@ -62,18 +62,16 @@ class PackagesGetCommand extends Command<int> {
6262 final targetPath = path.normalize (Directory (target).absolute.path);
6363 final isFlutterInstalled = await Flutter .installed ();
6464 if (isFlutterInstalled) {
65- final installDependenciesDone = _logger.progress (
66- 'Running "flutter packages get" in $targetPath ' ,
67- );
6865 try {
69- await Flutter .packagesGet (cwd: targetPath, recursive: recursive);
70- installDependenciesDone ();
66+ await Flutter .packagesGet (
67+ cwd: targetPath,
68+ recursive: recursive,
69+ progress: _logger.progress,
70+ );
7171 } on PubspecNotFound catch (_) {
72- installDependenciesDone ();
7372 _logger.err ('Could not find a pubspec.yaml in $targetPath ' );
7473 return ExitCode .noInput.code;
7574 } catch (error) {
76- installDependenciesDone ();
7775 _logger.err ('$error ' );
7876 return ExitCode .unavailable.code;
7977 }
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ void main() {
181181 logger.progress (
182182 any (that: contains ('Running "flutter packages get" in' )),
183183 );
184- }).called (1 );
184+ }).called (2 );
185185 });
186186 });
187187 });
You can’t perform that action at this time.
0 commit comments