Skip to content

Commit

Permalink
fix: support workspace-generators and workspace-schematics (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli authored Jan 7, 2022
1 parent ee21291 commit 8a2c48f
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions libs/server/src/lib/utils/get-generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ export async function getGenerators(

generatorCollections = [
...generatorCollections,
...(await checkAndReadWorkspaceGenerators(
basedir,
join('tools', 'schematics')
)),
...(await checkAndReadWorkspaceGenerators(
basedir,
join('tools', 'generators')
)),
...(await checkAndReadWorkspaceGenerators(basedir, 'schematics')),
...(await checkAndReadWorkspaceGenerators(basedir, 'generators')),
];
return generatorCollections.filter(
(collection): collection is CollectionInfo => !!collection.data
Expand All @@ -43,12 +37,14 @@ export async function getGenerators(

async function checkAndReadWorkspaceGenerators(
basedir: string,
workspaceGeneratorsPath: string
workspaceGeneratorType: 'generators' | 'schematics'
) {
const workspaceGeneratorsPath = join('tools', workspaceGeneratorType);
if (await directoryExists(join(basedir, workspaceGeneratorsPath))) {
const collection = await readWorkspaceGeneratorsCollection(
basedir,
workspaceGeneratorsPath
workspaceGeneratorsPath,
workspaceGeneratorType
);
return collection;
}
Expand All @@ -57,10 +53,13 @@ async function checkAndReadWorkspaceGenerators(

async function readWorkspaceGeneratorsCollection(
basedir: string,
workspaceGeneratorsPath: string
workspaceGeneratorsPath: string,
workspaceGeneratorType: 'generators' | 'schematics'
): Promise<CollectionInfo[]> {
const collectionDir = join(basedir, workspaceGeneratorsPath);
const collectionName = 'workspace-generator';
const collectionName = `workspace-${
workspaceGeneratorType === 'generators' ? 'generator' : 'schematic'
}`;
const collectionPath = join(collectionDir, 'collection.json');
if (await fileExists(collectionPath)) {
const collection = await readAndCacheJsonFile(
Expand Down

0 comments on commit 8a2c48f

Please sign in to comment.