electron/lib/common/electron-binding-setup.ts

14 lines
453 B
TypeScript
Raw Normal View History

export function electronBindingSetup (binding: typeof process['_linkedBinding'], processType: typeof process['type']): typeof process['electronBinding'] {
return function electronBinding (name: string) {
try {
2020-03-20 20:28:31 +00:00
return binding(`electron_${processType}_${name}`);
} catch (error) {
if (/No such module/.test(error.message)) {
2020-03-20 20:28:31 +00:00
return binding(`electron_common_${name}`);
} else {
2020-03-20 20:28:31 +00:00
throw error;
}
}
2020-03-20 20:28:31 +00:00
};
}