我正在尝试构建一个 Angular Schematics 来帮助我和我的团队快速创建 NgRx 操作。这是原理图功能,大部分是从各种教程中复制的:
export default (options: CCSchematicsAction): Rule => {
return (tree: Tree, _context: SchematicContext) => {
const modulePath = options.modulePath.replace(/-?module$/, ""); // "shared/application-tools"
const moduleFolder = normalize("src/app/" + modulePath); // "src/app/shared/application-tools"
const modulePathComponents = modulePath.split("/"); // ["shared", "application-tools"]
const moduleIdentifier = modulePathComponents
.map(part => classify(part))
.join(".")
+ ".Action"; // "Shared.ApplicationTools.Action"
const action = options.name.replace(/-?action$/, "");
const path = normalize(moduleFolder + "/action/" + action) + "/";
const templateSource = apply(url("./files"), [
template({
action: action,
moduleIdentifier: moduleIdentifier
}),
move(path)
]);
return chain([
mergeWith(templateSource)
])(tree, _context);
};
}
我用
schematics cc-generate:action load-stuff-action --modulePath shared/ui
并获得以下信息,我什至无法在网上找到任何信息:
TypeError: trustedSubscriber._addParentTeardownLogic is not a function
at MergeMapSubscriber.Subscriber [as constructor] (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/Subscriber.js:45:43)
at MergeMapSubscriber.OuterSubscriber [as constructor] (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/OuterSubscriber.js:20:42)
at new MergeMapSubscriber (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/operators/mergeMap.js:48:28)
at MergeMapOperator.call (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/operators/mergeMap.js:39:33)
at Observable.subscribe (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/Observable.js:24:22)
at DefaultIfEmptyOperator.call (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/defaultIfEmpty.js:24:23)
at Observable.subscribe (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/Observable.js:24:22)
at TakeLastOperator.call (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/takeLast.js:35:23)
at Observable.subscribe (/Users/voss/Development/cc/cc-schematics/node_modules/rxjs/internal/Observable.js:24:22)
at DoOperator.call (/usr/local/lib/node_modules/@angular-devkit/schematics-cli/node_modules/rxjs/internal/operators/tap.js:29:23)
编辑:
当我删除所有内容并返回一个空链时,错误仍然存在。
export default (_options: CCSchematicsAction): Rule => {
return (tree: Tree, _context: SchematicContext) => {
return chain([noop()])(tree, _context);
};
}
那么chain
函数有什么问题呢?