Skip to content

Stop debugger on TypeScript compile error #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/debug-adapter/webKitDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {

if (cliCommand.tnsProcess) {
this._tnsProcess = cliCommand.tnsProcess;
cliCommand.tnsOutputEventEmitter.on("tsCompilationError", () => {
this.fireEvent(new TerminatedEvent());
});
cliCommand.tnsProcess.stdout.on('data', data => { Services.logger().log(data.toString(), Tags.FrontendMessage); });
cliCommand.tnsProcess.stderr.on('data', data => { Services.logger().error(data.toString(), Tags.FrontendMessage); });
cliCommand.tnsProcess.on('close', (code, signal) => {
Expand Down
4 changes: 3 additions & 1 deletion src/project/androidProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export class AndroidProject extends Project {
return { tnsProcess: debugProcess, tnsOutputEventEmitter: tnsOutputEventEmitter };
}

private configureReadyEvent(readableStream: stream.Readable, eventEmitter: EventEmitter, attach: boolean): void {
protected configureReadyEvent(readableStream: stream.Readable, eventEmitter: EventEmitter, attach?: boolean): void {
super.configureReadyEvent(readableStream, eventEmitter);

let debugPort = null;
new scanner.StringMatchingScanner(readableStream).onEveryMatch(new RegExp("device: .* debug port: [0-9]+"), (match: scanner.MatchFound) => {
//device: {device-name} debug port: {debug-port}
Expand Down
4 changes: 3 additions & 1 deletion src/project/iosProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export class IosProject extends Project {
return { tnsProcess: debugProcess, tnsOutputEventEmitter: tnsOutputEventEmitter };
}

private configureReadyEvent(readableStream: stream.Readable, eventEmitter: EventEmitter): void {
protected configureReadyEvent(readableStream: stream.Readable, eventEmitter: EventEmitter): void {
super.configureReadyEvent(readableStream, eventEmitter);

let socketPathPrefix = 'socket-file-location: ';
let streamScanner = new scanner.StringMatchingScanner(readableStream);
streamScanner.onEveryMatch(new RegExp(socketPathPrefix + '.*\.sock'), (match: scanner.MatchFound) => {
Expand Down
8 changes: 8 additions & 0 deletions src/project/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {ChildProcess} from 'child_process';
import {EventEmitter} from 'events';
import {Version} from '../common/version';
import {NativeScriptCli} from './nativeScriptCli';
import * as stream from 'stream';
import * as scanner from './streamScanner';

export type DebugResult = { tnsProcess: ChildProcess, tnsOutputEventEmitter: EventEmitter };

Expand All @@ -28,6 +30,12 @@ export abstract class Project {

public abstract debug(options: { stopOnEntry: boolean, watch: boolean }, tnsArgs?: string[]): DebugResult;

protected configureReadyEvent(readableStream: stream.Readable, eventEmitter: EventEmitter): void {
new scanner.StringMatchingScanner(readableStream).onEveryMatch("TypeScript compiler failed", () => {
eventEmitter.emit('tsCompilationError');
});
}

protected executeRunCommand(args: string[]): ChildProcess {
return this.cli.execute(["run", this.platformName()].concat(args), this._appRoot);
}
Expand Down