Skip to content

Instantly share code, notes, and snippets.

@bniedermeyer
Last active March 1, 2019 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bniedermeyer/134f92bc28fed5c260613c59efff4fd0 to your computer and use it in GitHub Desktop.
Save bniedermeyer/134f92bc28fed5c260613c59efff4fd0 to your computer and use it in GitHub Desktop.
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