MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / getRpath

Function getRpath

src/util.ts:98–132  ·  view source on GitHub ↗
(quote = false, overwriteConfig?: string)

Source from the content-addressed store, hash-verified

96}
97
98export async function getRpath(quote = false, overwriteConfig?: string): Promise<string | undefined> {
99 let rpath: string | undefined = '';
100
101 // try the config entry specified in the function arg:
102 if (overwriteConfig) {
103 rpath = config().get<string>(overwriteConfig);
104 }
105
106 // try the os-specific config entry for the rpath:
107 const configEntry = getRPathConfigEntry();
108 rpath ||= config().get<string>(configEntry);
109 rpath &&= substituteVariables(rpath);
110
111 // read from path/registry:
112 rpath ||= await getRpathFromSystem();
113
114 // represent all invalid paths (undefined, '', null) as undefined:
115 rpath ||= undefined;
116
117 if (!rpath) {
118 // inform user about missing R path:
119 void vscode.window.showErrorMessage(`Cannot find R to use for help, package installation etc. Change setting r.${configEntry} to R path.`);
120 } else if (quote && /^[^'"].* .*[^'"]$/.exec(rpath)) {
121 // if requested and rpath contains spaces, add quotes:
122 rpath = `"${rpath}"`;
123 } else if (!quote) {
124 rpath = rpath.replace(/^"(.*)"$/, '$1');
125 rpath = rpath.replace(/^'(.*)'$/, '$1');
126 } else if (process.platform === 'win32' && /^'.* .*'$/.exec(rpath)) {
127 // replace single quotes with double quotes on windows
128 rpath = rpath.replace(/^'(.*)'$/, '"$1"');
129 }
130
131 return rpath;
132}
133
134export async function getRterm(): Promise<string | undefined> {
135 const configEntry = getRPathConfigEntry(true);

Callers 9

provideTasksMethod · 0.90
resolveTaskMethod · 0.90
createClientMethod · 0.90
getTemplateItemsFunction · 0.90
previewDocumentMethod · 0.90
initializeHelpFunction · 0.90
executeRCommandFunction · 0.85
promptToInstallRPackageFunction · 0.85

Calls 5

configFunction · 0.85
getRPathConfigEntryFunction · 0.85
substituteVariablesFunction · 0.85
getRpathFromSystemFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected