Merge pull request #676 from murgatroid99/proto_loader_resolve_fallback

proto loader: Fall back to default path resolution
This commit is contained in:
Michael Lumish 2018-12-07 15:06:25 -08:00 committed by GitHub
commit a4553f1a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -118,6 +118,7 @@ function createPackageDefinition(root: Protobuf.Root, options: Options): Package
} }
function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) { function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) {
const originalResolvePath = root.resolvePath;
root.resolvePath = (origin: string, target: string) => { root.resolvePath = (origin: string, target: string) => {
if (path.isAbsolute(target)) { if (path.isAbsolute(target)) {
return target; return target;
@ -131,7 +132,7 @@ function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) {
continue; continue;
} }
} }
throw new Error(`Could not find file ${target}`); return originalResolvePath(origin, target);
}; };
} }