Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import {
Rule,
SchematicContext,
Tree,
chain
} from '@angular-devkit/schematics';
import { Schema } from './schema.model.ts';
export function myAwesomeSchematic(_options: Schema): Rule {
return (tree: Tree, _context: SchematicContext) => {
return chain([
addDependencies(options),
addRequiredFiles(options)
])(tree, _context);
};
}
function addDependencies(options: Schema): Rule {
return (tree: Tree, _context: SchematicContext) => {
// this tells the schematic to run the add-dependencies schemtic found in collection.json as a task
_context.addTask(new RunSchematicTask('add-dependencies', options));
return tree;
};
function addRequiredFiles(options: Schema): Rule {
return (tree: Tree, _context: SchematicContext) => {
// this tells the schematic to run the add-files schemtic found in collection.json
_context.addTask(new RunSchematicTask('add-files', options));
return tree;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment