diff options
-rw-r--r-- | editors/code/src/extension.ts | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index d5b496b1b..f06c5445d 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -155,30 +155,21 @@ async function askToCargoWatch() { | |||
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | 157 | ||
158 | try { | 158 | const label = 'install-cargo-watch'; |
159 | // await vscode.tasks.executeTask(createTask({label: '', bin: 'cargo', args: ['install', 'cargo-watch'], env: {}})); | 159 | const taskFinished = new Promise((resolve, reject) => { |
160 | 160 | let disposable = vscode.tasks.onDidEndTask(({ execution }) => { | |
161 | const channel = vscode.window.createOutputChannel('cargo-watch'); | 161 | if (execution.task.name === label) { |
162 | channel.show(false); | 162 | disposable.dispose(); |
163 | const sup = spawn('cargo', ['install', 'cargo-watch']); | 163 | resolve(); |
164 | sup.stderr.on('data', chunk => { | 164 | }; |
165 | const output = new TextDecoder().decode(chunk); | ||
166 | channel.append(output); | ||
167 | }); | ||
168 | await new Promise((resolve, reject) => { | ||
169 | sup.on('close', (code, signal) => { | ||
170 | if (code === 0) { | ||
171 | resolve(code); | ||
172 | } else { | ||
173 | reject(code); | ||
174 | } | ||
175 | }); | ||
176 | }); | 165 | }); |
177 | channel.dispose(); | 166 | }); |
178 | } catch (err) { | 167 | |
179 | vscode.window.showErrorMessage( | 168 | vscode.tasks.executeTask(createTask({ label, bin: 'cargo', args: ['install', 'cargo-watch'], env: {} })); |
180 | `Couldn't install \`cargo-watch\`: ${err.message}` | 169 | await taskFinished; |
181 | ); | 170 | const { stderr } = await util.promisify(exec)('cargo watch --version').catch(e => e); |
171 | if (stderr !== '') { | ||
172 | vscode.window.showErrorMessage(`Couldn't install \`cargo-\`watch: ${stderr}`); | ||
182 | return; | 173 | return; |
183 | } | 174 | } |
184 | } | 175 | } |