()
| 61 | } |
| 62 | |
| 63 | export async function getRpathFromSystem(): Promise<string> { |
| 64 | |
| 65 | let rpath = ''; |
| 66 | const platform: string = process.platform; |
| 67 | |
| 68 | rpath ||= getRfromEnvPath(platform); |
| 69 | |
| 70 | if ( !rpath && platform === 'win32') { |
| 71 | // Find path from registry |
| 72 | try { |
| 73 | const key = new winreg({ |
| 74 | hive: winreg.HKLM, |
| 75 | key: '\\Software\\R-Core\\R', |
| 76 | }); |
| 77 | const item: winreg.RegistryItem = await new Promise((c, e) => |
| 78 | key.get('InstallPath', (err, result) => err === null ? c(result) : e(err))); |
| 79 | rpath = path.join(item.value, 'bin', 'R.exe'); |
| 80 | } catch (e) { |
| 81 | rpath = ''; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return rpath; |
| 86 | } |
| 87 | |
| 88 | export function getRPathConfigEntry(term: boolean = false): string { |
| 89 | const trunc = (term ? 'rterm' : 'rpath'); |
no test coverage detected