Skip to content

Commit c6127ea

Browse files
author
Dimitar Kerezov
committed
Fix chrome debug message
1 parent 64080f7 commit c6127ea

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

lib/commands/debug.ts

+5-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { EOL } from "os";
2-
3-
export abstract class DebugPlatformCommand implements ICommand {
1+
export abstract class DebugPlatformCommand implements ICommand {
42
public allowedParameters: ICommandParameter[] = [];
53
public platform: string;
64

@@ -12,7 +10,7 @@ export abstract class DebugPlatformCommand implements ICommand {
1210
protected $options: IOptions,
1311
protected $platformsData: IPlatformsData,
1412
protected $logger: ILogger,
15-
private $debugLiveSyncService: ILiveSyncService,
13+
private $debugLiveSyncService: IDebugLiveSyncService,
1614
private $config: IConfiguration) {
1715
this.$projectData.initializeProjectData();
1816
}
@@ -25,7 +23,7 @@ export abstract class DebugPlatformCommand implements ICommand {
2523
await this.$platformService.trackProjectType(this.$projectData);
2624

2725
if (this.$options.start) {
28-
return this.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
26+
return this.$debugLiveSyncService.printDebugInformation(await this.debugService.debug<string[]>(debugData, debugOptions));
2927
}
3028

3129
this.$config.debugLivesync = true;
@@ -96,12 +94,6 @@ export abstract class DebugPlatformCommand implements ICommand {
9694

9795
return true;
9896
}
99-
100-
protected printDebugInformation(information: string[]): void {
101-
_.each(information, i => {
102-
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${i}${EOL}`.cyan);
103-
});
104-
}
10597
}
10698

10799
export class DebugIOSCommand extends DebugPlatformCommand {
@@ -117,7 +109,7 @@ export class DebugIOSCommand extends DebugPlatformCommand {
117109
$projectData: IProjectData,
118110
$platformsData: IPlatformsData,
119111
$iosDeviceOperations: IIOSDeviceOperations,
120-
$debugLiveSyncService: ILiveSyncService) {
112+
$debugLiveSyncService: IDebugLiveSyncService) {
121113
super($iOSDebugService, $devicesService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger, $debugLiveSyncService, $config);
122114
// Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket.
123115
// In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket.
@@ -134,12 +126,6 @@ export class DebugIOSCommand extends DebugPlatformCommand {
134126
return await super.canExecute(args) && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.iOS);
135127
}
136128

137-
protected printDebugInformation(information: string[]): void {
138-
if (this.$options.chrome) {
139-
super.printDebugInformation(information);
140-
}
141-
}
142-
143129
public platform = this.$devicePlatformsConstants.iOS;
144130
}
145131

@@ -157,7 +143,7 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
157143
$options: IOptions,
158144
$projectData: IProjectData,
159145
$platformsData: IPlatformsData,
160-
$debugLiveSyncService: ILiveSyncService) {
146+
$debugLiveSyncService: IDebugLiveSyncService) {
161147
super($androidDebugService, $devicesService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger, $debugLiveSyncService, $config);
162148
}
163149

lib/definitions/livesync.d.ts

+12
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ interface ILiveSyncService {
146146
stopLiveSync(projectDir: string, deviceIdentifiers?: string[]): Promise<void>;
147147
}
148148

149+
/**
150+
* Describes LiveSync operations while debuggging.
151+
*/
152+
interface IDebugLiveSyncService extends ILiveSyncService {
153+
/**
154+
* Prints debug information.
155+
* @param {string[]} information Array of information to be printed. Note that false-like values will be stripped from the array.
156+
* @returns {void}
157+
*/
158+
printDebugInformation(information: string[]): void;
159+
}
160+
149161
interface ILiveSyncWatchInfo {
150162
projectData: IProjectData;
151163
filesToRemove: string[];

lib/services/livesync/debug-livesync-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EOL } from "os";
22
import { LiveSyncService } from "./livesync-service";
33

4-
export class DebugLiveSyncService extends LiveSyncService {
4+
export class DebugLiveSyncService extends LiveSyncService implements IDebugLiveSyncService {
55

66
constructor(protected $platformService: IPlatformService,
77
$projectDataService: IProjectDataService,
@@ -67,7 +67,8 @@ export class DebugLiveSyncService extends LiveSyncService {
6767
this.printDebugInformation(await debugService.debug<string[]>(debugData, debugOptions));
6868
}
6969

70-
protected printDebugInformation(information: string[]): void {
70+
public printDebugInformation(information: string[]): void {
71+
information = information.filter(i => !!i);
7172
_.each(information, i => {
7273
this.$logger.info(`To start debugging, open the following URL in Chrome:${EOL}${i}${EOL}`.cyan);
7374
});

0 commit comments

Comments
 (0)