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