Skip to content

Commit

Permalink
internal api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 14, 2023
1 parent e04a888 commit 9cc5518
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/composed-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class ComposedStore {
}

get customCommitTask() {
return this.getFeature('customCommitTask');
return this.findUniqueFeature('customCommitTask');
}

get customInstallTask() {
return this.getFeature('customInstallTask');
return this.findUniqueFeature('customInstallTask');
}

getGenerators(): Record<string, BaseGenerator> {
Expand Down Expand Up @@ -69,15 +69,18 @@ export class ComposedStore {
return this.uniqueByPathMap.get(root)!;
}

private getFeature(featureName: UniqueFeatureType) {
const providedFeatures: any[] = Object.entries(this.generators)
findFeature(featureName: string): any[] {
return Object.entries(this.generators)
.map(([generatorId, generator]) => {
const { features = (generator as any).getFeatures?.() } = generator;
const feature = features?.[featureName];
return feature ? [generatorId, feature] : undefined;
})
.filter(Boolean);
}

private findUniqueFeature(featureName: UniqueFeatureType) {
const providedFeatures = this.findFeature(featureName);
if (providedFeatures.length > 0) {
if (providedFeatures.length > 1) {
this.log?.info?.(
Expand Down

0 comments on commit 9cc5518

Please sign in to comment.