diff --git a/src/commands/optimize.ts b/src/commands/optimize.ts index 6665afb2ef6..fdb2a3ad6ed 100644 --- a/src/commands/optimize.ts +++ b/src/commands/optimize.ts @@ -84,9 +84,11 @@ export default class Optimize extends Command { this.optimizations = flags.optimization as Optimizations[]; this.outputMethod = flags.output as Outputs; + this.metricsMetadata.optimized = true; + if (!(report.moveToComponents?.length || report.removeComponents?.length || report.reuseComponents?.length)) { - this.metricsMetadata.optimized = false; this.log(`No optimization has been applied since ${this.specFile.getFilePath() ?? this.specFile.getFileURL()} looks optimized!`); + this.metricsMetadata.optimized = false; return; } @@ -102,7 +104,6 @@ export default class Optimize extends Command { reuseComponents: this.optimizations.includes(Optimizations.REUSE_COMPONENTS) }, output: Output.YAML}); - this.metricsMetadata.optimized = true; await this.collectMetricsData(report); const specPath = this.specFile.getFilePath(); @@ -138,8 +139,6 @@ export default class Optimize extends Command { return; } - this.metricsMetadata.optimized = true; - for (let i = 0; i < elements.length; i++) { const element = elements[+i]; if (element.action==='move') {