Skip to content

Commit

Permalink
Make install --force work for path dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Jun 6, 2024
1 parent 74f715e commit 01f4565
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions packages/realm_dart/lib/src/cli/install/install_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ class InstallCommand extends Command<void> {
return false;
}

Future<void> downloadAndExtractBinaries(Directory destinationDir, Version version, String archiveName) async {
Future<void> downloadAndExtractBinaries(Directory destinationDir, Version version, String archiveName, bool force) async {
if (await shouldSkipDownload(destinationDir.absolute.path, version.toString())) {
return;
if (!force) {
return;
}

print('Deleting existing binaries because --force was supplied.');
await destinationDir.delete(recursive: true);
}

if (!await destinationDir.exists()) {
Expand Down Expand Up @@ -130,8 +135,9 @@ class InstallCommand extends Command<void> {

final flavorName = flavor.packageName;
final realmDependency = pubspec.dependencyOverrides[flavorName] ?? pubspec.dependencies[flavorName];
if (realmDependency is PathDependency) {
print('Path dependency for $flavorName found. Skipping install of native lib (assuming local development)');
if (realmDependency is PathDependency && !options.force) {
print(
'Path dependency for $flavorName found. Skipping install of native lib (assuming local development). If you want to force install, add --force to the command invocation.');
return;
}
if (realmDependency == null) {
Expand All @@ -145,7 +151,7 @@ class InstallCommand extends Command<void> {
final binaryPath = getBinaryPath(realmPackagePath, isFlutter: flavor == Flavor.flutter);
print(binaryPath);
final archiveName = '${options.targetOsType!.name}.tar.gz';
await downloadAndExtractBinaries(binaryPath, realmPubspec.version!, archiveName);
await downloadAndExtractBinaries(binaryPath, realmPubspec.version!, archiveName, options.force);

print('Realm install command finished.');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/realm_dart/lib/src/cli/install/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Options {
@CliOption(hide: true, help: 'Download binary from http://localhost:8000/.', defaultsTo: false)
bool debug;

@CliOption(hide: true, help: 'Force install, even if we would normally skip it.', defaultsTo: false)
@CliOption(help: 'Force install, even if we would normally skip it.', abbr: 'f', defaultsTo: false)
bool force;

Options({this.targetOsType, this.force = false, this.debug = false});
Expand Down

0 comments on commit 01f4565

Please sign in to comment.