Skip to content

Commit

Permalink
fix findFeature api and type
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Nov 14, 2023
1 parent 5680430 commit 29eb6b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/composed-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ export class ComposedStore {
return this.uniqueByPathMap.get(root)!;
}

findFeature(featureName: string): any[] {
findFeature(featureName: string): Array<{ generatorId: string; feature: 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;
return feature ? { generatorId, feature } : undefined;
})
.filter(Boolean);
.filter(Boolean) as any;
}

private findUniqueFeature(featureName: UniqueFeatureType) {
const providedFeatures = this.findFeature(featureName);
if (providedFeatures.length > 0) {
if (providedFeatures.length > 1) {
this.log?.info?.(
`Multiple ${featureName} tasks found (${providedFeatures.map(([generatorId]) => generatorId).join(', ')}). Using the first.`,
`Multiple ${featureName} tasks found (${providedFeatures.map(({ generatorId }) => generatorId).join(', ')}). Using the first.`,
);
}

const [generatorId, feature] = providedFeatures[0];
const { generatorId, feature } = providedFeatures[0];
debug(`Feature ${featureName} provided by ${generatorId}`);
return feature;
}
Expand Down
2 changes: 1 addition & 1 deletion src/environment-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default class EnvironmentBase extends EventEmitter implements BaseEnviron
this.alias(/^([^:]+)$/, '$1:app');
}

findFeature(featureName: string): any[] {
findFeature(featureName: string): Array<{ generatorId: string; feature: any }> {
return this.composedStore.findFeature(featureName);
}

Expand Down

0 comments on commit 29eb6b0

Please sign in to comment.