(pkgNames: string[], skipConfirmation: boolean = false)
| 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; |
no test coverage detected