Skip to content

Commit 81ae8dd

Browse files
authored
Merge pull request #35 from badsyntax/fix-tasks-err-handling
Fix refresh task error handling
2 parents 7548430 + 6fb3301 commit 81ae8dd

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 2.1.4
4+
5+
- Fix refresh tasks error handling
6+
37
## 2.1.3
48

59
- Fix gradle tasks parsing #19

src/tasks.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,6 @@ async function detectGradleTasks(
166166
}
167167
}
168168

169-
export async function detectGradleTasksForFolder(
170-
folder: Uri,
171-
statusBarItem: StatusBarItem,
172-
outputChannel: OutputChannel
173-
): Promise<FolderTaskItem[]> {
174-
const folderTasks: FolderTaskItem[] = [];
175-
const tasks = await provideGradleTasksForFolder(
176-
folder,
177-
statusBarItem,
178-
outputChannel
179-
);
180-
folderTasks.push(...tasks.map(task => ({ label: task.name, task })));
181-
return folderTasks;
182-
}
183-
184169
export async function provideGradleTasks(
185170
statusBarItem: StatusBarItem,
186171
outputChannel: OutputChannel
@@ -356,17 +341,27 @@ function spawn(
356341
outputChannel.append(`Executing: ${command}\n`);
357342
}
358343
return new Promise((resolve, reject) => {
359-
const buffers: Buffer[] = [];
344+
const stdoutBuffers: Buffer[] = [];
345+
const stderrBuffers: Buffer[] = [];
360346
const child = cp.spawn(command, args, options);
361-
child.stdout.on('data', (b: Buffer) => buffers.push(b));
347+
child.stdout.on('data', (b: Buffer) => stdoutBuffers.push(b));
348+
child.stderr.on('data', (b: Buffer) => stderrBuffers.push(b));
362349
child.on('error', reject);
363350
child.on('exit', (code: number) => {
364351
if (code === 0) {
365352
resolve(
366-
Buffer.concat(buffers)
353+
Buffer.concat(stdoutBuffers)
367354
.toString('utf8')
368355
.trim()
369356
);
357+
} else {
358+
reject(
359+
new Error(
360+
Buffer.concat(stderrBuffers)
361+
.toString('utf8')
362+
.trim()
363+
)
364+
);
370365
}
371366
});
372367
});

0 commit comments

Comments
 (0)