gulpfile.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var gulp = require('gulp');
  2. var exec = require('child_process').exec;
  3. gulp.task('genproto_closure', function (cb) {
  4. exec('../src/protoc --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
  5. function (err, stdout, stderr) {
  6. console.log(stdout);
  7. console.log(stderr);
  8. cb(err);
  9. });
  10. });
  11. gulp.task('genproto_commonjs', function (cb) {
  12. exec('mkdir -p commonjs_out && ../src/protoc --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto',
  13. function (err, stdout, stderr) {
  14. console.log(stdout);
  15. console.log(stderr);
  16. cb(err);
  17. });
  18. });
  19. gulp.task('dist', function (cb) {
  20. // TODO(haberman): minify this more aggressively.
  21. // Will require proper externs/exports.
  22. exec('./node_modules/google-closure-library/closure/bin/calcdeps.py -i message.js -i binary/reader.js -i binary/writer.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > google-protobuf.js',
  23. function (err, stdout, stderr) {
  24. console.log(stdout);
  25. console.log(stderr);
  26. cb(err);
  27. });
  28. });
  29. gulp.task('deps', ['genproto_closure'], function (cb) {
  30. exec('./node_modules/google-closure-library/closure/bin/build/depswriter.py *.js binary/*.js > deps.js',
  31. function (err, stdout, stderr) {
  32. console.log(stdout);
  33. console.log(stderr);
  34. cb(err);
  35. });
  36. });
  37. gulp.task('test_closure', ['genproto_closure', 'deps'], function (cb) {
  38. exec('JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine',
  39. function (err, stdout, stderr) {
  40. console.log(stdout);
  41. console.log(stderr);
  42. cb(err);
  43. });
  44. });
  45. gulp.task('test_commonjs', ['genproto_commonjs', 'dist'], function (cb) {
  46. exec('JASMINE_CONFIG_PATH=jasmine.json cp jasmine_commonjs.json commonjs_out/jasmine.json && cd commonjs_out && ../node_modules/.bin/jasmine',
  47. function (err, stdout, stderr) {
  48. console.log(stdout);
  49. console.log(stderr);
  50. cb(err);
  51. });
  52. });