@@ -57,22 +57,22 @@ var group3Protos = [
5757 'test10.proto'
5858] ;
5959
60+ function make_exec_logging_callback ( cb ) {
61+ return ( err , stdout , stderr ) => {
62+ console . log ( stdout ) ;
63+ console . error ( stderr ) ;
64+ cb ( err ) ;
65+ }
66+ }
67+
6068function genproto_well_known_types_closure ( cb ) {
6169 exec ( protoc + ' --js_out=one_output_file_per_input_file,binary:. -I ' + protocInc + ' -I . ' + wellKnownTypes . join ( ' ' ) ,
62- function ( err , stdout , stderr ) {
63- console . log ( stdout ) ;
64- console . log ( stderr ) ;
65- cb ( err ) ;
66- } ) ;
70+ make_exec_logging_callback ( cb ) ) ;
6771}
6872
6973function genproto_group1_closure ( cb ) {
7074 exec ( protoc + ' --js_out=library=testproto_libs1,binary:. -I ' + protocInc + ' -I . ' + group1Protos . join ( ' ' ) ,
71- function ( err , stdout , stderr ) {
72- console . log ( stdout ) ;
73- console . log ( stderr ) ;
74- cb ( err ) ;
75- } ) ;
75+ make_exec_logging_callback ( cb ) ) ;
7676}
7777
7878function genproto_group2_closure ( cb ) {
@@ -81,68 +81,40 @@ function genproto_group2_closure(cb) {
8181 ' --experimental_allow_proto3_optional' +
8282 ' --js_out=library=testproto_libs2,binary:. -I ' + protocInc + ' -I . -I commonjs ' +
8383 group2Protos . join ( ' ' ) ,
84- function ( err , stdout , stderr ) {
85- console . log ( stdout ) ;
86- console . log ( stderr ) ;
87- cb ( err ) ;
88- } ) ;
84+ make_exec_logging_callback ( cb ) ) ;
8985}
9086
9187function genproto_well_known_types_commonjs ( cb ) {
9288 exec ( 'mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ' + protocInc + ' ' + wellKnownTypes . join ( ' ' ) ,
93- function ( err , stdout , stderr ) {
94- console . log ( stdout ) ;
95- console . log ( stderr ) ;
96- cb ( err ) ;
97- } ) ;
89+ make_exec_logging_callback ( cb ) ) ;
9890}
9991
10092function genproto_group1_commonjs ( cb ) {
10193 exec ( 'mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ' + protocInc + ' -I commonjs -I . ' + group1Protos . join ( ' ' ) ,
102- function ( err , stdout , stderr ) {
103- console . log ( stdout ) ;
104- console . log ( stderr ) ;
105- cb ( err ) ;
106- } ) ;
94+ make_exec_logging_callback ( cb ) ) ;
10795}
10896
10997function genproto_group2_commonjs ( cb ) {
11098 exec (
11199 'mkdir -p commonjs_out && ' + protoc +
112100 ' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ' + protocInc + ' -I commonjs -I . ' +
113101 group2Protos . join ( ' ' ) ,
114- function ( err , stdout , stderr ) {
115- console . log ( stdout ) ;
116- console . log ( stderr ) ;
117- cb ( err ) ;
118- } ) ;
102+ make_exec_logging_callback ( cb ) ) ;
119103}
120104
121105function genproto_commonjs_wellknowntypes ( cb ) {
122106 exec ( 'mkdir -p commonjs_out/node_modules/google-protobuf && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out/node_modules/google-protobuf -I ' + protocInc + ' ' + wellKnownTypes . join ( ' ' ) ,
123- function ( err , stdout , stderr ) {
124- console . log ( stdout ) ;
125- console . log ( stderr ) ;
126- cb ( err ) ;
127- } ) ;
107+ make_exec_logging_callback ( cb ) ) ;
128108}
129109
130110function genproto_wellknowntypes ( cb ) {
131111 exec ( protoc + ' --js_out=import_style=commonjs,binary:. -I ' + protocInc + ' ' + wellKnownTypes . join ( ' ' ) ,
132- function ( err , stdout , stderr ) {
133- console . log ( stdout ) ;
134- console . log ( stderr ) ;
135- cb ( err ) ;
136- } ) ;
112+ make_exec_logging_callback ( cb ) ) ;
137113}
138114
139115function genproto_group3_commonjs_strict ( cb ) {
140116 exec ( 'mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs_strict,binary:commonjs_out -I ' + protocInc + ' -I commonjs -I . ' + group3Protos . join ( ' ' ) ,
141- function ( err , stdout , stderr ) {
142- console . log ( stdout ) ;
143- console . log ( stderr ) ;
144- cb ( err ) ;
145- } ) ;
117+ make_exec_logging_callback ( cb ) ) ;
146118}
147119
148120
@@ -165,16 +137,7 @@ function gen_google_protobuf_js(cb) {
165137 var log_file = fs . createWriteStream ( '/usr/local/google/home/dibenede/gulp.log' , { flags :'w' } ) ;
166138 exec (
167139 getClosureCompilerCommand ( 'commonjs/export.js' , 'google-protobuf.js' ) ,
168- function ( err , stdout , stderr ) {
169- log_file . write ( 'building google-protobuf.js' ) ;
170- if ( err ) {
171- log_file . write ( 'there was an error:' , err ) ;
172- }
173- log_file . write ( 'done' ) ;
174- console . log ( stdout ) ;
175- console . log ( stderr ) ;
176- cb ( err ) ;
177- } ) ;
140+ make_exec_logging_callback ( cb ) ) ;
178141}
179142
180143
@@ -184,11 +147,7 @@ function commonjs_asserts(cb) {
184147 getClosureCompilerCommand (
185148 'commonjs/export_asserts.js' ,
186149 'commonjs_out/test_node_modules/closure_asserts_commonjs.js' ) ,
187- function ( err , stdout , stderr ) {
188- console . log ( stdout ) ;
189- console . log ( stderr ) ;
190- cb ( err ) ;
191- } ) ;
150+ make_exec_logging_callback ( cb ) ) ;
192151}
193152
194153function commonjs_testdeps ( cb ) {
@@ -197,11 +156,7 @@ function commonjs_testdeps(cb) {
197156 getClosureCompilerCommand (
198157 'commonjs/export_testdeps.js' ,
199158 'commonjs_out/test_node_modules/testdeps_commonjs.js' ) ,
200- function ( err , stdout , stderr ) {
201- console . log ( stdout ) ;
202- console . log ( stderr ) ;
203- cb ( err ) ;
204- } ) ;
159+ make_exec_logging_callback ( cb ) ) ;
205160}
206161
207162function commonjs_out ( cb ) {
@@ -222,51 +177,31 @@ function commonjs_out(cb) {
222177 'cp google-protobuf.js commonjs_out/test_node_modules && ' +
223178 'cp commonjs/strict_test.js commonjs_out/strict_test.js &&' +
224179 'cp commonjs/import_test.js commonjs_out/import_test.js' ,
225- function ( err , stdout , stderr ) {
226- console . log ( stdout ) ;
227- console . log ( stderr ) ;
228- cb ( err ) ;
229- } ) ;
180+ make_exec_logging_callback ( cb ) ) ;
230181}
231182
232183
233184
234185function closure_make_deps ( cb ) {
235186 exec (
236187 './node_modules/.bin/closure-make-deps --closure-path=. --file=node_modules/google-closure-library/closure/goog/deps.js binary/arith.js binary/constants.js binary/decoder.js binary/encoder.js binary/reader.js binary/utils.js binary/writer.js debug.js map.js message.js node_loader.js test_bootstrap.js > deps.js' ,
237- function ( err , stdout , stderr ) {
238- console . log ( stdout ) ;
239- console . log ( stderr ) ;
240- cb ( err ) ;
241- } ) ;
188+ make_exec_logging_callback ( cb ) ) ;
242189}
243190
244191function test_closure ( cb ) {
245192 exec (
246193 'JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine' ,
247- function ( err , stdout , stderr ) {
248- console . log ( stdout ) ;
249- console . log ( stderr ) ;
250- cb ( err ) ;
251- } ) ;
194+ make_exec_logging_callback ( cb ) ) ;
252195}
253196
254197function test_commonjs ( cb ) {
255198 exec ( 'cd commonjs_out && JASMINE_CONFIG_PATH=jasmine.json NODE_PATH=test_node_modules ../node_modules/.bin/jasmine' ,
256- function ( err , stdout , stderr ) {
257- console . log ( stdout ) ;
258- console . log ( stderr ) ;
259- cb ( err ) ;
260- } ) ;
199+ make_exec_logging_callback ( cb ) ) ;
261200}
262201
263202exports . build_protoc_plugin = function ( cb ) {
264203 exec ( 'bazel build generator:protoc-gen-js' ,
265- function ( err , stdout , stderr ) {
266- console . log ( stdout ) ;
267- console . log ( stderr ) ;
268- cb ( err ) ;
269- } ) ;
204+ make_exec_logging_callback ( cb ) ) ;
270205}
271206
272207exports . dist = series ( exports . build_protoc_plugin ,
0 commit comments