mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
@grpc/proto-loader: Fix absolute path handling and improve reporting of loading failures
This commit is contained in:
parent
fae76dec4a
commit
6364d0a92f
@ -119,6 +119,9 @@ function createPackageDefinition(root: Protobuf.Root, options: Options): Package
|
||||
|
||||
function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) {
|
||||
root.resolvePath = (origin: string, target: string) => {
|
||||
if (path.isAbsolute(target)) {
|
||||
return target;
|
||||
}
|
||||
for (const directory of includePaths) {
|
||||
const fullPath: string = path.join(directory, target);
|
||||
try {
|
||||
@ -128,7 +131,7 @@ function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new Error(`Could not find file ${target}`);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user