electron-binding-setup.ts 453 B

12345678910111213
  1. export function electronBindingSetup (binding: typeof process['_linkedBinding'], processType: typeof process['type']): typeof process['electronBinding'] {
  2. return function electronBinding (name: string) {
  3. try {
  4. return binding(`electron_${processType}_${name}`);
  5. } catch (error) {
  6. if (/No such module/.test(error.message)) {
  7. return binding(`electron_common_${name}`);
  8. } else {
  9. throw error;
  10. }
  11. }
  12. };
  13. }