Skip to content

Commit

Permalink
feat(core/generate): generate functions take a collection or a collec…
Browse files Browse the repository at this point in the history
…tion promise
  • Loading branch information
rafamel committed Oct 24, 2019
1 parent 5ce0ffc commit 379bc11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/generate/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ClientGenerateOptions {
}

export async function client(
collection: CollectionTree,
collection: CollectionTree | Promise<CollectionTree>,
resolver: (service: Service, info: ElementInfo) => string,
options?: ClientGenerateOptions
): Promise<string> {
Expand All @@ -48,6 +48,7 @@ export async function client(
};

let content = '';
collection = await collection;

if (opts.typescript) {
content += await typings(collection, {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/generate/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface TypingsGenerateOptions {
}

export async function typings(
collection: CollectionTree,
collection: CollectionTree | Promise<CollectionTree>,
options?: TypingsGenerateOptions
): Promise<string> {
const opts = { write: null, headComments: true, ...options };
Expand All @@ -29,7 +29,7 @@ export async function typings(
'/* This file was automatically generated. DO NOT MODIFY IT BY HAND. */\n\n';
}

const { types } = normalize(collection);
const { types } = normalize(await collection);
for (const [key, value] of Object.entries(types)) {
if (value.kind !== 'error') {
content += await compile(value.schema, key, { bannerComment: '' });
Expand Down

0 comments on commit 379bc11

Please sign in to comment.