mirror of
https://github.com/apple/pkl.git
synced 2026-04-18 06:29:45 +02: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;
|
return projectDepsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable Path getLocalPath(Dependency dependency) {
|
private @Nullable Path getLocalPath(Dependency dependency, PackageAssetUri packageAssetUri) {
|
||||||
if (!(dependency instanceof LocalDependency localDependency)) {
|
if (!(dependency instanceof LocalDependency localDependency)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -669,6 +669,13 @@ public final class ModuleKeys {
|
|||||||
getProjectDepsResolver().getProjectDir(), packageAssetUri);
|
getProjectDepsResolver().getProjectDir(), packageAssetUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @Nullable Path getLocalPath(Dependency dependency) {
|
||||||
|
if (!(dependency instanceof LocalDependency)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return getLocalPath(dependency, packageAssetUri);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResolvedModuleKey resolve(SecurityManager securityManager)
|
public ResolvedModuleKey resolve(SecurityManager securityManager)
|
||||||
throws IOException, SecurityManagerException {
|
throws IOException, SecurityManagerException {
|
||||||
@@ -693,7 +700,7 @@ public final class ModuleKeys {
|
|||||||
var packageAssetUri = PackageAssetUri.create(baseUri);
|
var packageAssetUri = PackageAssetUri.create(baseUri);
|
||||||
var dependency =
|
var dependency =
|
||||||
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
||||||
var path = getLocalPath(dependency);
|
var path = getLocalPath(dependency, packageAssetUri);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
securityManager.checkResolveModule(path.toUri());
|
securityManager.checkResolveModule(path.toUri());
|
||||||
return FileResolver.listElements(path);
|
return FileResolver.listElements(path);
|
||||||
@@ -710,7 +717,7 @@ public final class ModuleKeys {
|
|||||||
var packageAssetUri = PackageAssetUri.create(elementUri);
|
var packageAssetUri = PackageAssetUri.create(elementUri);
|
||||||
var dependency =
|
var dependency =
|
||||||
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
getProjectDepsResolver().getResolvedDependency(packageAssetUri.getPackageUri());
|
||||||
var path = getLocalPath(dependency);
|
var path = getLocalPath(dependency, packageAssetUri);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
securityManager.checkResolveModule(path.toUri());
|
securityManager.checkResolveModule(path.toUri());
|
||||||
return FileResolver.hasElement(path);
|
return FileResolver.hasElement(path);
|
||||||
|
|||||||
@@ -32,7 +32,16 @@ examples {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
["glob-import local project"] {
|
["glob-import local project"] {
|
||||||
new {}
|
new {
|
||||||
|
["@project2/penguin.pkl"] {
|
||||||
|
bird {
|
||||||
|
name = "Penguin"
|
||||||
|
favoriteFruit {
|
||||||
|
name = "Ice Fruit"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
["glob-import using dependency notation"] {
|
["glob-import using dependency notation"] {
|
||||||
Set("@birds/catalog/Ostritch.pkl", "@birds/catalog/Swallow.pkl")
|
Set("@birds/catalog/Ostritch.pkl", "@birds/catalog/Swallow.pkl")
|
||||||
|
|||||||
Reference in New Issue
Block a user