Moved CommonJS-specific files into commonjs directory
diff --git a/js/import_test.js b/js/commonjs/import_test.js similarity index 81% rename from js/import_test.js rename to js/commonjs/import_test.js index 6655685..ffa34fe 100644 --- a/js/import_test.js +++ b/js/commonjs/import_test.js
@@ -30,16 +30,18 @@ // Test suite is written using Jasmine -- see http://jasmine.github.io/ -goog.setTestOnly(); -goog.require('goog.json'); -goog.require('goog.testing.asserts'); -// CommonJS-LoadFromFile: google-protobuf jspb -goog.require('jspb.Message'); +var googleProtobuf = require('google-protobuf'); +var asserts = require('closure_asserts_commonjs'); +var global = Function('return this')(); -// CommonJS-LoadFromFile: test7/test7_pb proto.jspb.test.framing -goog.require('proto.jspb.test.framing.FramingMessage'); +// Bring asserts into the global namespace. +googleProtobuf.object.extend(global, asserts); +googleProtobuf.exportSymbol('jspb.Message', googleProtobuf.Message, global); + +var test7_pb = require('./test7/test7_pb'); +googleProtobuf.exportSymbol('proto.jspb.test.framing.FramingMessage', test7_pb.FramingMessage, global); describe('Import test suite', function() { it('testImportedMessage', function() {
diff --git a/js/test6/test6.proto b/js/commonjs/test6/test6.proto similarity index 99% rename from js/test6/test6.proto rename to js/commonjs/test6/test6.proto index 60c26f8..a060925 100644 --- a/js/test6/test6.proto +++ b/js/commonjs/test6/test6.proto
@@ -37,4 +37,4 @@ message ImportedMessage { string string_value = 1; -} \ No newline at end of file +}
diff --git a/js/test7/test7.proto b/js/commonjs/test7/test7.proto similarity index 99% rename from js/test7/test7.proto rename to js/commonjs/test7/test7.proto index 19d563d..f5574a3 100644 --- a/js/test7/test7.proto +++ b/js/commonjs/test7/test7.proto
@@ -39,4 +39,4 @@ message FramingMessage { jspb.test.importing.ImportedMessage imported_message = 1; -} \ No newline at end of file +}
diff --git a/js/gulpfile.js b/js/gulpfile.js index e8028b4..36fd9fd 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js
@@ -5,7 +5,7 @@ var protoc = process.env.PROTOC || '../src/protoc'; gulp.task('genproto_closure', function (cb) { - exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto test*/*.proto ../src/google/protobuf/descriptor.proto', + exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -14,7 +14,7 @@ }); gulp.task('genproto_commonjs', function (cb) { - exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto test*/*.proto ../src/google/protobuf/descriptor.proto', + exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto', function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -56,7 +56,8 @@ exec(cmd + 'cp commonjs/jasmine.json commonjs_out/jasmine.json && ' + - 'cp google-protobuf.js commonjs_out/test_node_modules', + 'cp google-protobuf.js commonjs_out/test_node_modules && ' + + 'cp commonjs/import_test.js commonjs_out/import_test.js', function (err, stdout, stderr) { console.log(stdout); console.log(stderr);