schematics-task
v0.2.9
Published
add and run task like schematics's NodePackageInstallTask
Downloads
46
Maintainers
Readme
schematics-task
add and run task like schematics's NodePackageInstallTask
TaskFn
import { Rule } from '@angular-devkit/schematics';
type TaskFn = Rule;
TaskFn
has no difference with a normal Rule
.
Export
addTask
, return aRule
, so you can use it like otherRule
generators.newTask
, task generate utility, then you can add the result tocontext.addTask
Usage
Use as a Rule
import { addTask } from 'schematics-task';
import { chain, Rule } from '@angular-devkit/schematics';
function foo(tree, context): Rule {
return chain([
// ...
addTask(async () => {
// Let's run a shell script
await execa('echo', ['hello', 'world'], {stdio: 'inherit'});
// do whatever you want
}),
]);
}
Use as a utility function
import { newTask } from 'schematics-task';
import { Tree, SchematicContext } from '@angular-devkit/schematics';
import execa from 'execa';
function foo(tree: Tree, context: SchematicContext) {
context.addTask(
newTask(async (_tree, _context) => {
// you can also use tree & context here
// Let's run a shell script
await execa('echo', ['hello', 'world'], {stdio: 'inherit'});
// do whatever you want
})
);
return tree;
}
License
MIT