generate_pbjs_files.js 576 B

12345678910111213141516171819202122232425
  1. var pbjs = require("./protobuf.js/cli").pbjs
  2. var argv = [];
  3. var protoFiles = [];
  4. var prefix = "";
  5. process.argv.forEach(function(val, index) {
  6. var arg = val;
  7. if (arg.length > 6 && arg.substring(arg.length - 6) == ".proto") {
  8. protoFiles.push(arg);
  9. } else if (arg.length > 15 && arg.substring(0, 15) == "--include_path=") {
  10. prefix = arg.substring(15);
  11. } else if (index >= 2) {
  12. argv.push(arg);
  13. }
  14. });
  15. protoFiles.forEach(function(val) {
  16. argv.push(prefix + "/" + val);
  17. });
  18. pbjs.main(argv, function(err, output){
  19. if (err) {
  20. console.log(err);
  21. }
  22. });