mirror of
https://github.com/apple/pkl.git
synced 2026-01-19 01:47:24 +01:00
Fix local dependency globbing (#496)
This fixes an issue where globbing resources within a local dependency fails to match anything.
This commit is contained in:
@@ -661,7 +661,7 @@ public final class ModuleKeys {
|
||||
return projectDepsManager;
|
||||
}
|
||||
|
||||
private @Nullable Path getLocalPath(Dependency dependency) {
|
||||
private @Nullable Path getLocalPath(Dependency dependency, PackageAssetUri packageAssetUri) {
|
||||
if (!(dependency instanceof LocalDependency localDependency)) {
|
||||
return null;
|
||||
}
|
||||
@@ -669,6 +669,13 @@ public final class ModuleKeys {
|
||||
getProjectDepsResolver().getProjectDir(), packageAssetUri);
|
||||
}
|
||||
|
||||
private @Nullable Path getLocalPath(Dependency dependency) {
|
||||
if (!(dependency instanceof LocalDependency)) {
|
||||
return null;
|
||||
}
|
||||
return getLocalPath(dependency, packageAssetUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResolvedModuleKey resolve(SecurityManager securityManager)
|
||||
throws IOException, SecurityManagerException {
|
||||
@@ -693,7 +700,7 @@ public final class ModuleKeys {
|
||||
var packageAssetUri = PackageAssetUri.create(baseUri);
|
||||
var dependency =
|
||||
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
||||
var path = getLocalPath(dependency);
|
||||
var path = getLocalPath(dependency, packageAssetUri);
|
||||
if (path != null) {
|
||||
securityManager.checkResolveModule(path.toUri());
|
||||
return FileResolver.listElements(path);
|
||||
@@ -710,7 +717,7 @@ public final class ModuleKeys {
|
||||
var packageAssetUri = PackageAssetUri.create(elementUri);
|
||||
var dependency =
|
||||
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
||||
var path = getLocalPath(dependency);
|
||||
var path = getLocalPath(dependency, packageAssetUri);
|
||||
if (path != null) {
|
||||
securityManager.checkResolveModule(path.toUri());
|
||||
return FileResolver.hasElement(path);
|
||||
|
||||
@@ -32,7 +32,16 @@ examples {
|
||||
}
|
||||
}
|
||||
["glob-import local project"] {
|
||||
new {}
|
||||
new {
|
||||
["@project2/penguin.pkl"] {
|
||||
bird {
|
||||
name = "Penguin"
|
||||
favoriteFruit {
|
||||
name = "Ice Fruit"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
["glob-import using dependency notation"] {
|
||||
Set("@birds/catalog/Ostritch.pkl", "@birds/catalog/Swallow.pkl")
|
||||
|
||||
Reference in New Issue
Block a user