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

Method installPackages

src/helpViewer/packages.ts:211–225  ·  view source on GitHub ↗
(pkgNames: string[], skipConfirmation: boolean = false)

Source from the content-addressed store, hash-verified

209 // actually install packages
210 // confirmation can be skipped (e.g. if the user has confimred before)
211 public async installPackages(pkgNames: string[], skipConfirmation: boolean = false): Promise<boolean> {
212 const rPath = this.rHelp.rPath;
213 const cranUrl = await getCranUrl('', this.cwd);
214 const args = [`--silent`, '--no-echo', `-e`, `install.packages(c(${pkgNames.map(v => `'${v}'`).join(',')}),repos='${cranUrl}')`];
215 const cmd = `${rPath} ${args.join(' ')}`;
216 const pluralS = pkgNames.length > 1? 's' : '';
217 const confirmation = `Yes, install package${pluralS}!`;
218 const prompt = `Are you sure you want to install package${pluralS}: ${pkgNames.join(', ')}?`;
219
220 if(skipConfirmation || await getConfirmation(prompt, confirmation, cmd)){
221 await executeAsTask('Install Package', rPath, args, true);
222 return true;
223 }
224 return false;
225 }
226
227 public async updatePackages(skipConfirmation: boolean = false): Promise<boolean> {
228 const rPath = this.rHelp.rPath;

Callers 2

_handleCommandMethod · 0.80

Calls 3

getCranUrlFunction · 0.90
getConfirmationFunction · 0.90
executeAsTaskFunction · 0.90

Tested by

no test coverage detected