clear the output before upload/verify

use the same channel for stdout and and stderr

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2020-07-21 19:52:59 +02:00
parent deea43008d
commit cc76f2bbc8
4 changed files with 23 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ export class CoreServiceImpl implements CoreService {
}
async compile(options: CoreService.Compile.Options): Promise<void> {
console.log('compile', options);
this.toolOutputService.publishNewOutput('compile', 'Compiling...\n' + JSON.stringify(options, null, 2) + '\n');
const { sketchUri, fqbn } = options;
const sketchFilePath = await this.fileSystem.getFsPath(sketchUri);
if (!sketchFilePath) {
@@ -67,21 +67,21 @@ export class CoreServiceImpl implements CoreService {
await new Promise<void>((resolve, reject) => {
result.on('data', (cr: CompileResp) => {
this.toolOutputService.publishNewOutput("compile", Buffer.from(cr.getOutStream_asU8()).toString());
this.toolOutputService.publishNewOutput("compile error", Buffer.from(cr.getErrStream_asU8()).toString());
this.toolOutputService.publishNewOutput("compile", Buffer.from(cr.getErrStream_asU8()).toString());
});
result.on('error', error => reject(error));
result.on('end', () => resolve());
});
this.toolOutputService.publishNewOutput("compile", "Compilation complete\n");
this.toolOutputService.publishNewOutput("compile", "Compilation complete.\n");
} catch (e) {
this.toolOutputService.publishNewOutput("compile error", `Compilation error: ${e}\n`);
this.toolOutputService.publishNewOutput("compile", `Compilation error: ${e}\n`);
throw e;
}
}
async upload(options: CoreService.Upload.Options): Promise<void> {
await this.compile(options);
console.log('upload', options);
this.toolOutputService.publishNewOutput('upload', 'Uploading...\n' + JSON.stringify(options, null, 2) + '\n');
const { sketchUri, fqbn } = options;
const sketchFilePath = await this.fileSystem.getFsPath(sketchUri);
if (!sketchFilePath) {
@@ -111,14 +111,14 @@ export class CoreServiceImpl implements CoreService {
await new Promise<void>((resolve, reject) => {
result.on('data', (cr: UploadResp) => {
this.toolOutputService.publishNewOutput("upload", Buffer.from(cr.getOutStream_asU8()).toString());
this.toolOutputService.publishNewOutput("upload error", Buffer.from(cr.getErrStream_asU8()).toString());
this.toolOutputService.publishNewOutput("upload", Buffer.from(cr.getErrStream_asU8()).toString());
});
result.on('error', error => reject(error));
result.on('end', () => resolve());
});
this.toolOutputService.publishNewOutput("upload", "Upload complete\n");
this.toolOutputService.publishNewOutput("upload", "Upload complete.\n");
} catch (e) {
this.toolOutputService.publishNewOutput("upload error", `Upload error: ${e}\n`);
this.toolOutputService.publishNewOutput("upload", `Upload error: ${e}\n`);
throw e;
}
}