(files: string[] = [])
| 3 | import logger from '../../logger' |
| 4 | |
| 5 | const openFiles = async (files: string[] = []): Promise<void> => { |
| 6 | if (!files.length) { |
| 7 | return |
| 8 | } |
| 9 | for (const filePath of files) { |
| 10 | try { |
| 11 | const workspaceFolders: readonly vscode.WorkspaceFolder[] | undefined = vscode.workspace.workspaceFolders |
| 12 | if (!workspaceFolders || !workspaceFolders.length) { |
| 13 | throw new Error('No workspace directory. Open a workspace directory and try again') |
| 14 | } |
| 15 | const wr: string = workspaceFolders[0].uri.path |
| 16 | const absoluteFilePath = join(wr, filePath) |
| 17 | const doc = await vscode.workspace.openTextDocument(absoluteFilePath) |
| 18 | await vscode.window.showTextDocument(doc, vscode.ViewColumn.One) |
| 19 | } catch (error: any) { |
| 20 | logger(`Failed to open file ${filePath}: ${error.message}`) |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | export default openFiles |
no test coverage detected