2019-03-18 12:37:06 -07:00
|
|
|
export function electronBindingSetup (binding: typeof process['_linkedBinding'], processType: typeof process['type']): typeof process['electronBinding'] {
|
|
|
|
return function electronBinding (name: string) {
|
2017-02-20 10:59:39 -03:00
|
|
|
try {
|
2020-03-20 13:28:31 -07:00
|
|
|
return binding(`electron_${processType}_${name}`);
|
2017-02-20 10:59:39 -03:00
|
|
|
} catch (error) {
|
|
|
|
if (/No such module/.test(error.message)) {
|
2020-03-20 13:28:31 -07:00
|
|
|
return binding(`electron_common_${name}`);
|
2017-02-20 10:59:39 -03:00
|
|
|
} else {
|
2020-03-20 13:28:31 -07:00
|
|
|
throw error;
|
2017-02-20 10:59:39 -03:00
|
|
|
}
|
|
|
|
}
|
2020-03-20 13:28:31 -07:00
|
|
|
};
|
2017-02-20 10:59:39 -03:00
|
|
|
}
|