MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / getAliasesFromR

Method getAliasesFromR

src/helpViewer/helpProvider.ts:248–285  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246
247 // call R script `getAliases.R` and parse the output
248 private async getAliasesFromR(): Promise<undefined | AllPackageAliases> {
249 const lim = '---vsc---';
250 const options: cp.CommonOptions = {
251 cwd: this.cwd,
252 env: {
253 ...process.env,
254 VSCR_LIB_PATHS: getRLibPaths(),
255 VSCR_LIM: lim,
256 VSCR_USE_RENV_LIB_PATH: config().get<boolean>('useRenvLibPath') ? 'TRUE' : 'FALSE'
257 }
258 };
259
260 const args = [
261 '--silent',
262 '--no-echo',
263 '--no-save',
264 '--no-restore',
265 '-f',
266 this.rScriptFile
267 ];
268
269 try {
270 const result = await spawnAsync(this.rPath, args, options);
271 if (result.status !== 0) {
272 throw result.error || new Error(result.stderr);
273 }
274 const re = new RegExp(`${lim}(.*)${lim}`, 'ms');
275 const match = re.exec(result.stdout);
276 if (match?.length !== 2) {
277 throw new Error('Could not parse R output.');
278 }
279 const json = match[1];
280 return <AllPackageAliases>JSON.parse(json) || {};
281 } catch (e) {
282 console.log(e);
283 void window.showErrorMessage(catchAsError(e).message);
284 }
285 }
286}

Callers 1

makeAllAliasesMethod · 0.95

Calls 5

getRLibPathsFunction · 0.90
configFunction · 0.90
spawnAsyncFunction · 0.90
catchAsErrorFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected