Skip to content

Commit 16c6ec9

Browse files
authored
fix(config-merge): mark an aspect with minus when it needs to be removed (teambit#6831)
1 parent 1fecc91 commit 16c6ec9

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

scopes/component/merging/config-merger.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ export class ConfigMerger {
111111
// exist in other but not in current and base, so it got created on other.
112112
return { id, mergedConfig: this.getConfig(otherExt) };
113113
});
114-
const envResult = this.envStrategy();
115-
return new ConfigMergeResult(this.compIdStr, compact([...results, ...otherAspectsNotHandledResults, envResult]));
114+
const envResult = [this.envStrategy()] || [];
115+
return new ConfigMergeResult(this.compIdStr, compact([...results, ...otherAspectsNotHandledResults, ...envResult]));
116116
}
117117

118118
private populateEnvs() {
@@ -137,19 +137,19 @@ export class ConfigMerger {
137137
if (currentEnvAspect) {
138138
this.handledExtIds.push(currentEnvAspect.stringId);
139139
this.currentEnv.version = currentEnvAspect.extensionId?.version;
140-
this.currentEnv.config = currentEnvAspect.rawConfig;
140+
this.currentEnv.config = this.getConfig(currentEnvAspect);
141141
}
142142
const otherEnvAspect = this.otherAspects.findExtension(otherEnv, true);
143143
if (otherEnvAspect) {
144144
this.handledExtIds.push(otherEnvAspect.stringId);
145145
this.otherEnv.version = otherEnvAspect.extensionId?.version;
146-
this.otherEnv.config = otherEnvAspect.rawConfig;
146+
this.otherEnv.config = this.getConfig(otherEnvAspect);
147147
}
148148
if (this.baseEnv) {
149149
const baseEnvAspect = this.baseAspects.findExtension(baseEnv, true);
150150
if (baseEnvAspect) {
151151
this.baseEnv.version = baseEnvAspect.extensionId?.version;
152-
this.baseEnv.config = baseEnvAspect.rawConfig;
152+
this.baseEnv.config = this.getConfig(baseEnvAspect);
153153
}
154154
}
155155
}
@@ -222,13 +222,15 @@ export class ConfigMerger {
222222
let conflict: string;
223223
if (currentConfig === '-') {
224224
conflict = `${'<'.repeat(7)} ${this.currentLabel}
225+
"${id}": "-"
225226
=======
226227
"${id}": ${JSON.stringify(otherConfig, undefined, 2)}
227228
${'>'.repeat(7)} ${this.otherLabel}`;
228229
} else if (otherConfig === '-') {
229230
conflict = `${'<'.repeat(7)} ${this.currentLabel}
230-
"${id}": ${JSON.stringify(otherConfig, undefined, 2)}
231+
"${id}": ${JSON.stringify(currentConfig, undefined, 2)}
231232
=======
233+
"${id}": "-"
232234
${'>'.repeat(7)} ${this.otherLabel}`;
233235
} else {
234236
const formatConfig = (conf: GenericConfigOrRemoved) => {
@@ -519,7 +521,7 @@ ${'>'.repeat(7)} ${this.otherLabel}`;
519521
return id === this.currentEnv.id || id === this.otherEnv.id;
520522
}
521523

522-
private getConfig(ext: ExtensionDataEntry) {
524+
private getConfig(ext: ExtensionDataEntry): GenericConfigOrRemoved {
523525
if (ext.rawConfig === '-') return ext.rawConfig;
524526
return omit(ext.rawConfig, ['__specific']);
525527
}

0 commit comments

Comments
 (0)