From bf8a1ebe7d70a451af89dc2601c6b3f52eb12286 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 10 May 2016 17:55:29 -0700 Subject: [PATCH 1/2] Fix encoding and piping problems with Node plugin wrapper --- tools/bin/protoc.js | 5 +++-- tools/bin/protoc_plugin.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/bin/protoc.js b/tools/bin/protoc.js index 4d50c94b..3bd1b84f 100755 --- a/tools/bin/protoc.js +++ b/tools/bin/protoc.js @@ -51,6 +51,7 @@ execFile(protoc, process.argv.slice(2), function(error, stdout, stderr) { if (error) { throw error; } - console.log(stdout); - console.log(stderr); }); + +child_process.stdout.pipe(process.stdout); +child_process.stderr.pipe(process.stderr); diff --git a/tools/bin/protoc_plugin.js b/tools/bin/protoc_plugin.js index 281ec0d8..857882e1 100755 --- a/tools/bin/protoc_plugin.js +++ b/tools/bin/protoc_plugin.js @@ -47,10 +47,12 @@ var exe_ext = process.platform === 'win32' ? '.exe' : ''; var plugin = path.resolve(__dirname, 'grpc_node_plugin' + exe_ext); -execFile(plugin, process.argv.slice(2), function(error, stdout, stderr) { +var child_process = execFile(plugin, process.argv.slice(2), {encoding: 'buffer'}, function(error, stdout, stderr) { if (error) { throw error; } - console.log(stdout); - console.log(stderr); }); + +process.stdin.pipe(child_process.stdin); +child_process.stdout.pipe(process.stdout); +child_process.stderr.pipe(process.stderr); From 01c1746826753e39dfa407e95665d2f4eb76e649 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 10 May 2016 17:56:29 -0700 Subject: [PATCH 2/2] Fixed variable --- tools/bin/protoc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bin/protoc.js b/tools/bin/protoc.js index 3bd1b84f..53fc5dc4 100755 --- a/tools/bin/protoc.js +++ b/tools/bin/protoc.js @@ -47,7 +47,7 @@ var exe_ext = process.platform === 'win32' ? '.exe' : ''; var protoc = path.resolve(__dirname, 'protoc' + exe_ext); -execFile(protoc, process.argv.slice(2), function(error, stdout, stderr) { +var child_process = execFile(protoc, process.argv.slice(2), function(error, stdout, stderr) { if (error) { throw error; }