fix: detect api from the list by the root file match (#903)

* fix: detect api from the list by the root file match

* chore: fix prettier
This commit is contained in:
Roman Hotsiy
2022-10-10 12:56:58 -05:00
committed by GitHub
parent 25ceadd093
commit 7685ce1445
3 changed files with 29 additions and 31 deletions

View File

@@ -48,7 +48,14 @@ function isNotEmptyArray<T>(args?: T[]): boolean {
function getAliasOrPath(config: Config, aliasOrPath: string): Entrypoint {
return config.apis[aliasOrPath]
? { path: config.apis[aliasOrPath]?.root, alias: aliasOrPath }
: { path: aliasOrPath };
: {
path: aliasOrPath,
// find alias by path, take the first match
alias:
Object.entries(config.apis).find(([_alias, api]) => {
return path.resolve(api.root) === path.resolve(aliasOrPath);
})?.[0] ?? undefined,
};
}
async function expandGlobsInEntrypoints(args: string[], config: Config) {