Skip to content

Commit 78c2e51

Browse files
authored
chore(cli): Wait for package config (#613)
Ideally, wait for pub to exit (dart-lang/sdk#55289).
1 parent 96ff874 commit 78c2e51

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/cli/lib/pub/pub_action.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:io';
23

34
import 'package:celest_cli_common/celest_cli_common.dart';
45
import 'package:cli_script/cli_script.dart';
@@ -33,6 +34,9 @@ Future<void> runPub({
3334
},
3435
workingDirectory: workingDirectory,
3536
);
37+
// TODO(dnys1): Remove when fixed in pub https://github.com/dart-lang/sdk/issues/55289
38+
// and we can rely on the exit code taking a reasonable amount of time.
39+
3640
// Must be sync so that completer only completes once before `finally` block
3741
// cancels subscription.
3842
final completer = Completer<void>.sync();
@@ -62,7 +66,18 @@ Future<void> runPub({
6266
);
6367
}
6468
}),
65-
completer.future,
69+
completer.future.then((_) {
70+
final packageConfig = fileSystem
71+
.directory(workingDirectory)
72+
.childDirectory('.dart_tool')
73+
.childFile('package_config.json');
74+
if (packageConfig.existsSync()) {
75+
return Future<void>.value();
76+
}
77+
return packageConfig
78+
.watch()
79+
.firstWhere((event) => event.type == FileSystemEvent.create);
80+
}),
6681
]);
6782
} finally {
6883
unawaited(stdout.cancel());

0 commit comments

Comments
 (0)