UNPKG

2.27 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14var schematics_1 = require("@angular-devkit/schematics");
15var schematics_core_1 = require("../../schematics-core");
16function default_1(options) {
17 return function (host, context) {
18 var projectConfig = (0, schematics_core_1.getProject)(host, options);
19 options.path = (0, schematics_core_1.getProjectPath)(host, options);
20 options.prefix = (0, schematics_core_1.getPrefix)(options);
21 var parsedPath = (0, schematics_core_1.parseName)(options.path, options.name);
22 options.name = parsedPath.name;
23 options.path = parsedPath.path;
24 if (options.module) {
25 options.module = (0, schematics_core_1.findModuleFromOptions)(host, options);
26 }
27 var templateOptions = __assign(__assign(__assign({}, schematics_core_1.stringUtils), { 'if-flat': function (s) {
28 return schematics_core_1.stringUtils.group(options.flat ? '' : s, options.group ? 'reducers' : '');
29 } }), options);
30 var templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
31 options.skipTests
32 ? (0, schematics_1.filter)(function (path) { return !path.endsWith('.spec.ts.template'); })
33 : (0, schematics_1.noop)(),
34 (0, schematics_1.applyTemplates)(templateOptions),
35 (0, schematics_1.move)(parsedPath.path),
36 ]);
37 return (0, schematics_1.chain)([
38 (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([(0, schematics_core_1.addReducerToState)(options)])),
39 (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([(0, schematics_core_1.addReducerImportToNgModule)(options), (0, schematics_1.mergeWith)(templateSource)])),
40 ])(host, context);
41 };
42}
43exports.default = default_1;
44//# sourceMappingURL=index.js.map
\No newline at end of file