0.2.9 • Published 3 years ago

schematics-task v0.2.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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 a Rule, so you can use it like other Rule generators.
  • newTask, task generate utility, then you can add the result to context.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

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago