aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorIgor Matuszewski <[email protected]>2019-03-18 20:13:49 +0000
committerIgor Matuszewski <[email protected]>2019-03-18 20:13:49 +0000
commit4bd61430622fcd289de1374c9e7c8d9260f38cf3 (patch)
tree06db4faf928ebe8ac2414bd80115c9fc0c718242 /editors
parent21b73f984433ca6ca1500826af59f8dd8bc22618 (diff)
Prefer installing `cargo-watch` via Task API
This gives us much more fine-grained stdout buffering and ANSI terminal colors.
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/extension.ts37
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 }