Skip to content

Commit cc76f2b

Browse files
author
Akos Kitta
committed
clear the output before upload/verify
use the same channel for stdout and and stderr Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent deea430 commit cc76f2b

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

arduino-ide-extension/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@theia/navigator": "next",
2929
"@theia/outline-view": "next",
3030
"@theia/preferences": "next",
31+
"@theia/output": "next",
3132
"@theia/search-in-workspace": "next",
3233
"@theia/terminal": "next",
3334
"@theia/workspace": "next",

arduino-ide-extension/src/browser/contributions/upload-sketch.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { inject, injectable } from 'inversify';
2+
import { OutputChannelManager } from '@theia/output/lib/common/output-channel';
23
import { CoreService } from '../../common/protocol';
3-
import { MonitorConnection } from '../monitor/monitor-connection';
4-
import { BoardsDataStore } from '../boards/boards-data-store';
5-
import { BoardsServiceClientImpl } from '../boards/boards-service-client-impl';
64
import { ArduinoMenus } from '../menu/arduino-menus';
75
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
6+
import { BoardsDataStore } from '../boards/boards-data-store';
7+
import { MonitorConnection } from '../monitor/monitor-connection';
8+
import { BoardsServiceClientImpl } from '../boards/boards-service-client-impl';
89
import { SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, TabBarToolbarRegistry } from './contribution';
910

1011
@injectable()
@@ -22,6 +23,9 @@ export class UploadSketch extends SketchContribution {
2223
@inject(BoardsServiceClientImpl)
2324
protected readonly boardsServiceClientImpl: BoardsServiceClientImpl;
2425

26+
@inject(OutputChannelManager)
27+
protected readonly outputChannelManager: OutputChannelManager;
28+
2529
registerCommands(registry: CommandRegistry): void {
2630
registry.registerCommand(UploadSketch.Commands.UPLOAD_SKETCH, {
2731
execute: () => this.uploadSketch()
@@ -78,6 +82,7 @@ export class UploadSketch extends SketchContribution {
7882
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`);
7983
}
8084
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn);
85+
this.outputChannelManager.getChannel('Arduino: upload').clear();
8186
await this.coreService.upload({
8287
sketchUri: uri,
8388
fqbn,

arduino-ide-extension/src/browser/contributions/verify-sketch.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { inject, injectable } from 'inversify';
2+
import { OutputChannelManager } from '@theia/output/lib/common/output-channel';
3+
import { CoreService } from '../../common/protocol';
24
import { ArduinoMenus } from '../menu/arduino-menus';
35
import { ArduinoToolbar } from '../toolbar/arduino-toolbar';
46
import { BoardsDataStore } from '../boards/boards-data-store';
57
import { BoardsServiceClientImpl } from '../boards/boards-service-client-impl';
68
import { SketchContribution, Command, CommandRegistry, MenuModelRegistry, KeybindingRegistry, TabBarToolbarRegistry } from './contribution';
7-
import { CoreService } from '../../common/protocol';
89

910
@injectable()
1011
export class VerifySketch extends SketchContribution {
@@ -18,6 +19,9 @@ export class VerifySketch extends SketchContribution {
1819
@inject(BoardsServiceClientImpl)
1920
protected readonly boardsServiceClientImpl: BoardsServiceClientImpl;
2021

22+
@inject(OutputChannelManager)
23+
protected readonly outputChannelManager: OutputChannelManager;
24+
2125
registerCommands(registry: CommandRegistry): void {
2226
registry.registerCommand(VerifySketch.Commands.VERIFY_SKETCH, {
2327
execute: () => this.verifySketch()
@@ -66,6 +70,7 @@ export class VerifySketch extends SketchContribution {
6670
throw new Error(`No core is installed for the '${boardsConfig.selectedBoard.name}' board. Please install the core.`);
6771
}
6872
const fqbn = await this.boardsDataStore.appendConfigToFqbn(boardsConfig.selectedBoard.fqbn);
73+
this.outputChannelManager.getChannel('Arduino: compile').clear();
6974
await this.coreService.compile({
7075
sketchUri: uri,
7176
fqbn,

arduino-ide-extension/src/node/core-service-impl.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class CoreServiceImpl implements CoreService {
3535
}
3636

3737
async compile(options: CoreService.Compile.Options): Promise<void> {
38-
console.log('compile', options);
38+
this.toolOutputService.publishNewOutput('compile', 'Compiling...\n' + JSON.stringify(options, null, 2) + '\n');
3939
const { sketchUri, fqbn } = options;
4040
const sketchFilePath = await this.fileSystem.getFsPath(sketchUri);
4141
if (!sketchFilePath) {
@@ -67,21 +67,21 @@ export class CoreServiceImpl implements CoreService {
6767
await new Promise<void>((resolve, reject) => {
6868
result.on('data', (cr: CompileResp) => {
6969
this.toolOutputService.publishNewOutput("compile", Buffer.from(cr.getOutStream_asU8()).toString());
70-
this.toolOutputService.publishNewOutput("compile error", Buffer.from(cr.getErrStream_asU8()).toString());
70+
this.toolOutputService.publishNewOutput("compile", Buffer.from(cr.getErrStream_asU8()).toString());
7171
});
7272
result.on('error', error => reject(error));
7373
result.on('end', () => resolve());
7474
});
75-
this.toolOutputService.publishNewOutput("compile", "Compilation complete\n");
75+
this.toolOutputService.publishNewOutput("compile", "Compilation complete.\n");
7676
} catch (e) {
77-
this.toolOutputService.publishNewOutput("compile error", `Compilation error: ${e}\n`);
77+
this.toolOutputService.publishNewOutput("compile", `Compilation error: ${e}\n`);
7878
throw e;
7979
}
8080
}
8181

8282
async upload(options: CoreService.Upload.Options): Promise<void> {
8383
await this.compile(options);
84-
console.log('upload', options);
84+
this.toolOutputService.publishNewOutput('upload', 'Uploading...\n' + JSON.stringify(options, null, 2) + '\n');
8585
const { sketchUri, fqbn } = options;
8686
const sketchFilePath = await this.fileSystem.getFsPath(sketchUri);
8787
if (!sketchFilePath) {
@@ -111,14 +111,14 @@ export class CoreServiceImpl implements CoreService {
111111
await new Promise<void>((resolve, reject) => {
112112
result.on('data', (cr: UploadResp) => {
113113
this.toolOutputService.publishNewOutput("upload", Buffer.from(cr.getOutStream_asU8()).toString());
114-
this.toolOutputService.publishNewOutput("upload error", Buffer.from(cr.getErrStream_asU8()).toString());
114+
this.toolOutputService.publishNewOutput("upload", Buffer.from(cr.getErrStream_asU8()).toString());
115115
});
116116
result.on('error', error => reject(error));
117117
result.on('end', () => resolve());
118118
});
119-
this.toolOutputService.publishNewOutput("upload", "Upload complete\n");
119+
this.toolOutputService.publishNewOutput("upload", "Upload complete.\n");
120120
} catch (e) {
121-
this.toolOutputService.publishNewOutput("upload error", `Upload error: ${e}\n`);
121+
this.toolOutputService.publishNewOutput("upload", `Upload error: ${e}\n`);
122122
throw e;
123123
}
124124
}

0 commit comments

Comments
 (0)