fix: lookup library in correct locations

This commit is contained in:
Aleksey Kulikov 2022-06-08 15:12:42 +03:00
parent 5739de545b
commit 7aadefc7b5
3 changed files with 21 additions and 32 deletions

View file

@ -23,15 +23,23 @@ Future<void> copyLibrary(String platform) async {
);
}
} else {
final pubCache = PubCache();
final pubCacheDir =
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
String? checkCache(PubCache pubCache) =>
pubCache.getLatestVersion('libgit2dart')?.resolve()?.location.path;
final libPath = checkCache(PubCache()) ??
checkCache(
PubCache(
Directory(
path.join(Platform.environment['FLUTTER_ROOT']!, '.pub-cache'),
),
),
);
final libName = getLibName();
stdout.writeln('Copying libgit2 for $platform');
final destination = path.join(libDir, platform);
Directory(destination).createSync(recursive: true);
File(path.join(pubCacheDir.path, platform, libName)).copySync(
File(path.join(libPath!, platform, libName)).copySync(
path.join(destination, libName),
);