Skip to content

Instantly share code, notes, and snippets.

@radekwarisch
Last active January 31, 2021 12:59
Show Gist options
  • Save radekwarisch/f4a6fbb949cb7624a12b41938c626893 to your computer and use it in GitHub Desktop.
Save radekwarisch/f4a6fbb949cb7624a12b41938c626893 to your computer and use it in GitHub Desktop.
Gather options function
export const gatherOptions = <TInputType>(schema: ComponentSchemaType) => async (
tree: Tree,
context: SchematicContext
): TInputType => {
const {classify} = strings;
const {name, 'parent-file-name': parentFileName} = schema;
const fileName = classify(name);
const config = loadConfigFromFile({tree});
const parentPath = await resolveParentPath({tree, parentFileName});
const {
componentsPath,
templatesPath
} = config;
const templateVariables = {
...schema,
...strings,
...getComponentTemplateVariables(schema, config),
};
return {
config,
fileName,
templatesPath,
componentsPath,
movePath,
templateVariables,
parentPath,
tree,
context,
schema,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment