-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathiosProject.ts
61 lines (50 loc) · 2.42 KB
/
iosProject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {ChildProcess} from 'child_process';
import * as stream from 'stream';
import {EventEmitter} from 'events';
import {Project, DebugResult} from './project';
import * as scanner from './streamScanner';
import {Version} from '../common/version';
import {NativeScriptCli} from './nativeScriptCli';
import {Services} from '../services/debugAdapterServices';
import {Tags} from '../common/logger';
export class IosProject extends Project {
constructor(appRoot: string, cli: NativeScriptCli) {
super(appRoot, cli);
if (!this.isPlatformOSX()) {
throw new Error('iOS platform is supported only on OS X.');
}
}
public platformName(): string {
return "ios";
}
public attach(tnsArgs?: string[]): DebugResult {
let args: string[] = ["--start"];
args = args.concat(tnsArgs);
let debugProcess : ChildProcess = super.executeDebugCommand(args);
let tnsOutputEventEmitter: EventEmitter = new EventEmitter();
this.configureReadyEvent(debugProcess.stdout, tnsOutputEventEmitter);
return { tnsProcess: debugProcess, tnsOutputEventEmitter: tnsOutputEventEmitter };
}
public debug(options: { stopOnEntry: boolean, watch: boolean }, tnsArgs?: string[]): DebugResult {
let args: string[] = [];
args.push(options.watch ? "--watch" : "--no-watch");
if (options.stopOnEntry) { args.push("--debug-brk"); }
args = args.concat(tnsArgs);
let debugProcess : ChildProcess = super.executeDebugCommand(args);
let tnsOutputEventEmitter: EventEmitter = new EventEmitter();
this.configureReadyEvent(debugProcess.stdout, tnsOutputEventEmitter);
return { tnsProcess: debugProcess, tnsOutputEventEmitter: tnsOutputEventEmitter };
}
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) => {
let socketPath = (<string>match.matches[0]).substr(socketPathPrefix.length);
eventEmitter.emit('readyForConnection', socketPath);
});
}
private isPlatformOSX(): boolean {
return /^darwin/.test(process.platform);
}
}