All files / service index.ts

100% Statements 16/16
94.44% Branches 17/18
100% Functions 3/3
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  2x 2x 2x   2x 4x 4x   4x 4x     4x 4x 4x   4x 4x 4x   4x          
import {Schema as ServiceOptions} from './schema';
import {chain, externalSchematic, Rule, Tree} from '@angular-devkit/schematics';
import {parseName} from '@schematics/angular/utility/parse-name';
import {getProjectSchematic, getSourceRoot} from '../utils/yang-utils';
 
export default function (options: ServiceOptions): Rule {
  return async (host: Tree) => {
    const rootPath = getSourceRoot(host, options);
 
    Eif (!options.path) {
      options.path = `${rootPath}/services`;
    }
 
    const parsedPath = parseName(options.path, options.name);
    options.name = parsedPath.name;
    options.path = parsedPath.path;
 
    const schematic = await getProjectSchematic(host, options, '@schematics/angular:service');
    options.flat = options.flat ?? schematic.flat ?? true;
    options.skipTests = options.skipTests ?? schematic.skipTests ?? false;
 
    return chain([
      externalSchematic('@schematics/angular', 'service', options)
    ]);
  };
}