1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const core_1 = require("@angular-devkit/core");
|
11 | const schematics_1 = require("@angular-devkit/schematics");
|
12 | const lint_fix_1 = require("../utility/lint-fix");
|
13 | const parse_name_1 = require("../utility/parse-name");
|
14 | const workspace_1 = require("../utility/workspace");
|
15 | function default_1(options) {
|
16 | return async (host) => {
|
17 | if (options.path === undefined) {
|
18 | options.path = await workspace_1.createDefaultPath(host, options.project);
|
19 | }
|
20 | const parsedPath = parse_name_1.parseName(options.path, options.name);
|
21 | options.name = parsedPath.name;
|
22 | options.path = parsedPath.path;
|
23 | const templateSource = schematics_1.apply(schematics_1.url('./files'), [
|
24 | options.skipTests ? schematics_1.filter(path => !path.endsWith('.spec.ts.template')) : schematics_1.noop(),
|
25 | schematics_1.applyTemplates({
|
26 | ...core_1.strings,
|
27 | 'if-flat': (s) => options.flat ? '' : s,
|
28 | ...options,
|
29 | }),
|
30 | schematics_1.move(parsedPath.path),
|
31 | ]);
|
32 | return schematics_1.chain([
|
33 | schematics_1.mergeWith(templateSource),
|
34 | options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
|
35 | ]);
|
36 | };
|
37 | }
|
38 | exports.default = default_1;
|