(path: string = '', cwd?: string | URL)
| 316 | // currently the CRAN root url is hardcoded, this could be replaced by reading |
| 317 | // the url from config, R, or both |
| 318 | export async function getCranUrl(path: string = '', cwd?: string | URL): Promise<string> { |
| 319 | const defaultCranUrl = 'https://cran.r-project.org/'; |
| 320 | // get cran URL from R. Returns empty string if option is not set. |
| 321 | const baseUrl = await executeRCommand('cat(getOption(\'repos\')[\'CRAN\'])', cwd); |
| 322 | let url: string; |
| 323 | try { |
| 324 | url = new URL(path, baseUrl).toString(); |
| 325 | } catch (e) { |
| 326 | url = new URL(path, defaultCranUrl).toString(); |
| 327 | } |
| 328 | return url; |
| 329 | } |
| 330 | |
| 331 | export async function getRVersion(cwd?: string | URL): Promise<string | undefined> { |
| 332 | return await executeRCommand('cat(as.character(getRversion()))', cwd); |
no test coverage detected