From 6364d0a92f72afe364b2bdf74f392fc782aa4305 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 17 Oct 2018 15:33:57 -0700 Subject: [PATCH] @grpc/proto-loader: Fix absolute path handling and improve reporting of loading failures --- packages/grpc-protobufjs/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/grpc-protobufjs/src/index.ts b/packages/grpc-protobufjs/src/index.ts index bb757762..099f990c 100644 --- a/packages/grpc-protobufjs/src/index.ts +++ b/packages/grpc-protobufjs/src/index.ts @@ -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}`); }; }