| 56 | } |
| 57 | |
| 58 | async configureTask(properties: ITaskConfigurationProperties) { |
| 59 | await this.quickaccess.openFileQuickAccessAndWait('tasks.json', 'tasks.json'); |
| 60 | await this.quickinput.selectQuickInputElement(0); |
| 61 | await this.quickaccess.runCommand('editor.action.selectAll'); |
| 62 | await this.code.dispatchKeybinding('Delete', async () => { |
| 63 | // TODO https://github.com/microsoft/vscode/issues/242535 |
| 64 | await wait(100); |
| 65 | }); |
| 66 | const taskStringLines: string[] = [ |
| 67 | '{', // Brackets auto close |
| 68 | '"version": "2.0.0",', |
| 69 | '"tasks": [{' // Brackets auto close |
| 70 | ]; |
| 71 | for (let [key, value] of Object.entries(properties)) { |
| 72 | if (typeof value === 'object') { |
| 73 | value = JSON.stringify(value); |
| 74 | } else if (typeof value === 'boolean') { |
| 75 | value = value; |
| 76 | } else if (typeof value === 'string') { |
| 77 | value = `"${value}"`; |
| 78 | } else { |
| 79 | throw new Error('Unsupported task property value type'); |
| 80 | } |
| 81 | taskStringLines.push(`"${key}": ${value},`); |
| 82 | } |
| 83 | for (const [i, line] of taskStringLines.entries()) { |
| 84 | await this.editor.waitForTypeInEditor('tasks.json', `${line}`); |
| 85 | if (i !== taskStringLines.length - 1) { |
| 86 | await this.code.dispatchKeybinding('Enter', async () => { |
| 87 | // TODO https://github.com/microsoft/vscode/issues/242535 |
| 88 | await wait(100); |
| 89 | }); |
| 90 | } |
| 91 | } |
| 92 | await this.editors.saveOpenedFile(); |
| 93 | } |
| 94 | } |