UNPKG

1.39 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4* @license
5* Copyright Google Inc. All Rights Reserved.
6*
7* Use of this source code is governed by an MIT-style license that can be
8* found in the LICENSE file at https://angular.io/license
9*/
10const core_1 = require("@angular-devkit/core");
11const schematics_1 = require("@angular-devkit/schematics");
12const lint_fix_1 = require("../utility/lint-fix");
13const parse_name_1 = require("../utility/parse-name");
14const workspace_1 = require("../utility/workspace");
15function 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 schematics_1.applyTemplates({
25 ...core_1.strings,
26 ...options,
27 }),
28 schematics_1.move(parsedPath.path),
29 ]);
30 return schematics_1.chain([
31 schematics_1.mergeWith(templateSource),
32 options.lintFix ? lint_fix_1.applyLintFix(options.path) : schematics_1.noop(),
33 ]);
34 };
35}
36exports.default = default_1;