server.js 783 B

1234567891011121314151617181920212223242526
  1. const child_process = require('child_process');
  2. const fs = require('fs');
  3. const path = require('path');
  4. const source = path.join('source');
  5. const target = path.join('dist', 'pypi', 'netron');
  6. if (fs.existsSync(target)) {
  7. fs.rmdirSync(target, { recursive: true });
  8. }
  9. fs.mkdirSync(target, { recursive: true });
  10. for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
  11. if (entry.isFile()) {
  12. fs.copyFileSync(path.join(source, entry.name), path.join(target, entry.name));
  13. }
  14. }
  15. const options = { stdio: 'inherit' };
  16. options.env = Object.assign({}, process.env);
  17. options.env.PYTHONPATH = path.join('dist', 'pypi');
  18. const args = [ '-c', 'import netron; netron.main()' ].concat(process.argv.slice(2));
  19. child_process.spawnSync('python', args, options);