()
| 6 | import { executeRCommand, getCurrentWorkspaceFolder } from './util'; |
| 7 | |
| 8 | export async function createLintrConfig(): Promise<string | undefined> { |
| 9 | const currentWorkspaceFolder = getCurrentWorkspaceFolder()?.uri.fsPath; |
| 10 | if (currentWorkspaceFolder === undefined) { |
| 11 | void window.showWarningMessage('Please open a workspace folder to create .lintr'); |
| 12 | return; |
| 13 | } |
| 14 | const lintrFilePath = join(currentWorkspaceFolder, '.lintr'); |
| 15 | if (existsSync(lintrFilePath)) { |
| 16 | const overwrite = await window.showWarningMessage( |
| 17 | '".lintr" file already exists. Do you want to overwrite?', |
| 18 | 'Yes', 'No' |
| 19 | ); |
| 20 | if (overwrite === 'No') { |
| 21 | return; |
| 22 | } |
| 23 | void unlinkSync(lintrFilePath); |
| 24 | } |
| 25 | return await executeRCommand(`lintr::use_lintr()`, currentWorkspaceFolder, (e: Error) => { |
| 26 | void window.showErrorMessage(e.message); |
| 27 | return ''; |
| 28 | }); |
| 29 | } |
nothing calls this directly
no test coverage detected