Skip to content

Commit 09adbb9

Browse files
committed
chore: track prepare with hook and extract getCircularReplacer in method
1 parent 258d6c5 commit 09adbb9

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/services/performance-service.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,9 @@ export class PerformanceService implements IPerformanceService {
5757

5858
private logDataToFile(filePath: string, methodInfo: string, executionTime: number, args: any[]) {
5959
let methodArgs;
60-
const getCircularReplacer = () => {
61-
const seen = new WeakSet();
62-
seen.add(this.$options);
63-
return (key: any, value: any) => {
64-
if (typeof value === "object" && value !== null) {
65-
if (seen.has(value) || _.startsWith(key, "$")) {
66-
return;
67-
}
68-
seen.add(value);
69-
}
70-
return value;
71-
};
72-
};
7360

7461
try {
75-
methodArgs = JSON.stringify(args, getCircularReplacer());
62+
methodArgs = JSON.stringify(args, this.getCircularReplacer());
7663
} catch (e) {
7764
methodArgs = "cyclic args";
7865
}
@@ -90,6 +77,20 @@ export class PerformanceService implements IPerformanceService {
9077
this.$logger.trace(PerformanceService.FAIL_LOG_MESSAGE_TEMPLATE, methodInfo);
9178
}
9279
}
80+
81+
private getCircularReplacer() {
82+
const seen = new WeakSet();
83+
seen.add(this.$options);
84+
return (key: any, value: any) => {
85+
if (typeof value === "object" && value !== null) {
86+
if (seen.has(value) || _.startsWith(key, "$")) {
87+
return;
88+
}
89+
seen.add(value);
90+
}
91+
return value;
92+
};
93+
}
9394
}
9495

9596
$injector.register('performanceService', PerformanceService);

lib/services/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ export class PlatformService extends EventEmitter implements IPlatformService {
307307
}
308308

309309
/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
310-
@helpers.hook('prepare')
311310
@performanceLog()
311+
@helpers.hook('prepare')
312312
private async preparePlatformCore(platform: string,
313313
appFilesUpdaterOptions: IAppFilesUpdaterOptions,
314314
projectData: IProjectData,

0 commit comments

Comments
 (0)