chore: Move the drift_offline_first to legacy in favor of Serverpod implementation (#32)
This commit is contained in:
parent
027aec5ed0
commit
cbc472523b
1 changed files with 13575 additions and 284 deletions
|
|
@ -1,39 +0,0 @@
|
|||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:cli_tools/src/logger/helpers/progress.dart';
|
||||
|
||||
Progress? _trackedAnimationInProgress;
|
||||
|
||||
Future<T> runWithProgress<T>(
|
||||
String message,
|
||||
Future<T> Function() runner, {
|
||||
bool Function(T result)? validator,
|
||||
bool skipProgress = false,
|
||||
}) async {
|
||||
if (skipProgress) {
|
||||
return Isolate.run(runner);
|
||||
}
|
||||
|
||||
_stopAnimationInProgress();
|
||||
final progress = Progress(message, stdout);
|
||||
_trackedAnimationInProgress = progress;
|
||||
final result = await Isolate.run(runner);
|
||||
_trackedAnimationInProgress = null;
|
||||
if (validator?.call(result) ?? true) {
|
||||
progress.complete();
|
||||
} else {
|
||||
progress.fail();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void _stopAnimationInProgress() {
|
||||
if (_trackedAnimationInProgress != null) {
|
||||
_trackedAnimationInProgress?.stopAnimation();
|
||||
// Since animation modifies the current line we add a new line so that
|
||||
// the next print doesn't end up on the same line.
|
||||
stdout.write('\n');
|
||||
}
|
||||
_trackedAnimationInProgress = null;
|
||||
}
|
||||
Loading…
Reference in a new issue