testProtocPlugin.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. const path = require('path');
  2. const GrpcToolsNodeProtocPlugin = require('./GrpcToolsNodeProtocPlugin.js');
  3. const glob = require('glob');
  4. // Define the paths as they are in your Webpack script
  5. const buildRootPath = path.join(process.cwd(), '..', '..', '..');
  6. const ComponentsPath = glob.sync(path.join(buildRootPath, 'components/'))[0];
  7. const buildCRootPath = glob.sync(buildRootPath)[0];
  8. // Instantiate the plugin
  9. const plugin = new GrpcToolsNodeProtocPlugin({
  10. protoPaths: [
  11. path.join(ComponentsPath, 'spotify/cspot/bell/external/nanopb/generator/proto'),
  12. path.join(buildCRootPath, 'protobuf/proto')
  13. ],
  14. protoSources: [
  15. path.join(buildCRootPath, 'protobuf/proto/*.proto'),
  16. path.join(ComponentsPath, 'spotify/cspot/bell/external/nanopb/generator/proto/*.proto')
  17. ],
  18. outputDir: './src/js/proto'
  19. });
  20. // Manually execute the plugin
  21. plugin.apply({
  22. hooks: {
  23. environment: {
  24. tap: (name, fn) => fn()
  25. }
  26. }
  27. });
  28. console.log('GrpcToolsNodeProtocPlugin test executed.');