From 6fb3301b3915532ed7a2fabe84e69fae21cf3aeb Mon Sep 17 00:00:00 2001 From: Richard Willis Date: Thu, 7 Nov 2019 21:11:58 +0100 Subject: [PATCH] Fix refresh task error handling --- CHANGELOG.md | 4 ++++ src/tasks.ts | 31 +++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db9ed0a..3e632dc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 2.1.4 + +- Fix refresh tasks error handling + ## 2.1.3 - Fix gradle tasks parsing #19 diff --git a/src/tasks.ts b/src/tasks.ts index b7fe3a12..fa02fae9 100644 --- a/src/tasks.ts +++ b/src/tasks.ts @@ -166,21 +166,6 @@ async function detectGradleTasks( } } -export async function detectGradleTasksForFolder( - folder: Uri, - statusBarItem: StatusBarItem, - outputChannel: OutputChannel -): Promise { - const folderTasks: FolderTaskItem[] = []; - const tasks = await provideGradleTasksForFolder( - folder, - statusBarItem, - outputChannel - ); - folderTasks.push(...tasks.map(task => ({ label: task.name, task }))); - return folderTasks; -} - export async function provideGradleTasks( statusBarItem: StatusBarItem, outputChannel: OutputChannel @@ -356,17 +341,27 @@ function spawn( outputChannel.append(`Executing: ${command}\n`); } return new Promise((resolve, reject) => { - const buffers: Buffer[] = []; + const stdoutBuffers: Buffer[] = []; + const stderrBuffers: Buffer[] = []; const child = cp.spawn(command, args, options); - child.stdout.on('data', (b: Buffer) => buffers.push(b)); + child.stdout.on('data', (b: Buffer) => stdoutBuffers.push(b)); + child.stderr.on('data', (b: Buffer) => stderrBuffers.push(b)); child.on('error', reject); child.on('exit', (code: number) => { if (code === 0) { resolve( - Buffer.concat(buffers) + Buffer.concat(stdoutBuffers) .toString('utf8') .trim() ); + } else { + reject( + new Error( + Buffer.concat(stderrBuffers) + .toString('utf8') + .trim() + ) + ); } }); });