mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
fix: lookup library in Dart's and Flutter's .pub-cache
This commit is contained in:
parent
d901d2e13f
commit
12ee9f3b53
1 changed files with 19 additions and 15 deletions
|
@ -35,9 +35,7 @@ String? _resolveLibPath(String name) {
|
||||||
var libPath = path.join(Directory.current.path, name);
|
var libPath = path.join(Directory.current.path, name);
|
||||||
|
|
||||||
// If lib is in Present Working Directory.
|
// If lib is in Present Working Directory.
|
||||||
if (_doesFileExist(libPath)) {
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
return libPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If lib is in Present Working Directory's '.dart_tool/libgit2/[platform]' folder.
|
// If lib is in Present Working Directory's '.dart_tool/libgit2/[platform]' folder.
|
||||||
libPath = path.join(
|
libPath = path.join(
|
||||||
|
@ -46,23 +44,29 @@ String? _resolveLibPath(String name) {
|
||||||
Platform.operatingSystem,
|
Platform.operatingSystem,
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
if (_doesFileExist(libPath)) {
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
return libPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If lib is in Present Working Directory's '[platform]' folder.
|
// If lib is in Present Working Directory's '[platform]' folder.
|
||||||
libPath = path.join(Directory.current.path, Platform.operatingSystem, name);
|
libPath = path.join(Directory.current.path, Platform.operatingSystem, name);
|
||||||
if (_doesFileExist(libPath)) {
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
return libPath;
|
|
||||||
|
String checkCache(PubCache pubCache) {
|
||||||
|
final pubCacheDir =
|
||||||
|
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
|
||||||
|
return path.join(pubCacheDir.path, Platform.operatingSystem, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If lib is in '.pub_cache' folder.
|
// If lib is in Dart's '.pub_cache' folder.
|
||||||
final pubCache = PubCache();
|
libPath = checkCache(PubCache());
|
||||||
final pubCacheDir =
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
pubCache.getLatestVersion('libgit2dart')!.resolve()!.location;
|
|
||||||
libPath = path.join(pubCacheDir.path, Platform.operatingSystem, name);
|
// If lib is in Flutter's '.pub_cache' folder.
|
||||||
if (_doesFileExist(libPath)) {
|
final env = Platform.environment;
|
||||||
return libPath;
|
if (env.containsKey('FLUTTER_ROOT')) {
|
||||||
|
final flutterPubCache =
|
||||||
|
PubCache(Directory(path.join(env['FLUTTER_ROOT']!, '.pub-cache')));
|
||||||
|
libPath = checkCache(flutterPubCache);
|
||||||
|
if (_doesFileExist(libPath)) return libPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue