Merge pull request #577 from murgatroid99/proto_loader_abs_path_fix

@grpc/proto-loader: Fix absolute path handling and improve reporting of loading failures
This commit is contained in:
Michael Lumish 2018-10-18 09:03:37 -07:00 committed by GitHub
commit eddfe265bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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}`);
};
}