Skip to content

Commit 9e76511

Browse files
committed
Stop adding new line at the end of frontend messages
1 parent 8bf938c commit 9e76511

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/common/logger.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,19 @@ export namespace Tags {
7373

7474
export namespace Handlers {
7575
export function stdStreamsHandler(args: LoggerMessageEventArgs) {
76+
var message = args.message.replace(/\n$/, "");
7677
switch(args.type) {
7778
case LoggerMessageType.Log:
78-
console.log(args.message);
79+
console.log(message);
7980
break;
8081
case LoggerMessageType.Info:
81-
console.info(args.message);
82+
console.info(message);
8283
break;
8384
case LoggerMessageType.Warning:
84-
console.warn(args.message);
85+
console.warn(message);
8586
break;
8687
case LoggerMessageType.Error:
87-
console.error(args.message);
88+
console.error(message);
8889
break;
8990
}
9091
};

src/debug-adapter/webKitDebugAdapter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
4040
private _webKitConnection: INSDebugConnection;
4141
private _eventHandler: (event: DebugProtocol.Event) => void;
4242
private _lastOutputEvent: OutputEvent;
43-
private _loggerFrontendHandler: LoggerHandler = args => this.fireEvent(new OutputEvent(`${args.message}\n`, args.type.toString()));
43+
private _loggerFrontendHandler: LoggerHandler = args => this.fireEvent(new OutputEvent(`${args.message}`, args.type.toString()));
4444
private _request: DebugRequest;
4545
private _tnsProcess: ChildProcess;
4646

@@ -143,8 +143,8 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
143143
Services.extensionClient().analyticsLaunchDebugger({ request: args.request, platform: args.platform });
144144

145145
// Run CLI Command
146-
Services.logger().log(`[NSDebugAdapter] Using tns CLI v${this._request.project.cli.version.version} on path '${this._request.project.cli.path}'`, Tags.FrontendMessage);
147-
Services.logger().log('[NSDebugAdapter] Running tns command...', Tags.FrontendMessage);
146+
Services.logger().log(`[NSDebugAdapter] Using tns CLI v${this._request.project.cli.version.version} on path '${this._request.project.cli.path}'\n`, Tags.FrontendMessage);
147+
Services.logger().log('[NSDebugAdapter] Running tns command...\n', Tags.FrontendMessage);
148148
let cliCommand: DebugResult;
149149
if (this._request.isLaunch) {
150150
let tnsArgs = this._request.args.tnsArgs;
@@ -173,7 +173,7 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
173173
cliCommand.tnsProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
174174
cliCommand.tnsProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
175175
cliCommand.tnsProcess.on('close', (code, signal) => {
176-
Services.logger().error(`[NSDebugAdapter] The tns command finished its execution with code ${code}.`, Tags.FrontendMessage);
176+
Services.logger().error(`[NSDebugAdapter] The tns command finished its execution with code ${code}.\n`, Tags.FrontendMessage);
177177

178178
// Sometimes we execute "tns debug android --start" and the process finishes
179179
// which is totally fine. If there's an error we need to Terminate the session.
@@ -185,18 +185,18 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
185185

186186
let promiseResolve = null;
187187
let promise: Promise<void> = new Promise<void>((res, rej) => { promiseResolve = res; });
188-
Services.logger().log('[NSDebugAdapter] Watching the tns CLI output to receive a connection token', Tags.FrontendMessage);
188+
Services.logger().log('[NSDebugAdapter] Watching the tns CLI output to receive a connection token\n', Tags.FrontendMessage);
189189
// Attach to the running application
190190
cliCommand.tnsOutputEventEmitter.on('readyForConnection', (connectionToken: string | number) => {
191-
Services.logger().log(`[NSDebugAdapter] Ready to attach to application on ${connectionToken}`, Tags.FrontendMessage);
191+
Services.logger().log(`[NSDebugAdapter] Ready to attach to application on ${connectionToken}\n`, Tags.FrontendMessage);
192192
let connection: INSDebugConnection = this._request.isAndroid ? new AndroidConnection() : new IosConnection();
193193

194194
connection.attach(connectionToken, 'localhost').then(() => {
195-
Services.logger().log(`[NSDebugAdapter] Connection to target application established on ${connectionToken}`, Tags.FrontendMessage);
195+
Services.logger().log(`[NSDebugAdapter] Connection to target application established on ${connectionToken}\n`, Tags.FrontendMessage);
196196
this.setConnection(connection);
197197
return connection.enable();
198198
}).then(() => {
199-
Services.logger().log(`[NSDebugAdapter] Connection to target application successfully enabled`, Tags.FrontendMessage);
199+
Services.logger().log(`[NSDebugAdapter] Connection to target application successfully enabled\n`, Tags.FrontendMessage);
200200
this.fireEvent(new InitializedEvent());
201201
promiseResolve();
202202
}).then(() => {});

src/project/nativeScriptCli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ export class NativeScriptCli {
8585
public executeSync(args: string[], cwd: string): string {
8686
args.unshift("--analyticsClient", "VSCode");
8787
let command: string = `${this._path} ${args.join(' ')}`;
88-
this._logger.log(`[NativeScriptCli] execute: ${command}`, Tags.FrontendMessage);
88+
this._logger.log(`[NativeScriptCli] execute: ${command}\n`, Tags.FrontendMessage);
8989

9090
return execSync(command, { encoding: "utf8", cwd: cwd, shell: this._shellPath}).toString().trim();
9191
}
9292

9393
public execute(args: string[], cwd: string): ChildProcess {
9494
args.unshift("--analyticsClient", "VSCode");
9595
let command: string = `${this._path} ${args.join(' ')}`;
96-
this._logger.log(`[NativeScriptCli] execute: ${command}`, Tags.FrontendMessage);
96+
this._logger.log(`[NativeScriptCli] execute: ${command}\n`, Tags.FrontendMessage);
9797

9898
let options = { cwd: cwd, shell: this._shellPath };
9999
let child: ChildProcess = spawn(this._path, args, options);

0 commit comments

Comments
 (0)