【发布时间】:2021-06-26 00:54:09
【问题描述】:
无法运行自定义 ng 更新原理图。目标是遍历 html 文件并搜索某些 dom 属性,但是我不确定如何在 Angular 应用程序中正确遍历 Tree 结构。我在网上没有找到很多关于这个的信息,我希望在这里能得到一些结果。下面是我目前尝试访问文件系统的规则工厂。
export default function MigrationUpdate(_options: any): Rule {
return (host: Tree, _context: SchematicContext) => {
//Traverse file system in angular application
//Searching for html files
host.getDir('/files').visit(filePath => {
if (!filePath.endsWith('.html')) {
return;
}
const text = host.read(filePath);
if (text === null) {
throw new SchematicsException('Unable to read file path.');
}
});
return host;
};
}
【问题讨论】:
标签: typescript abstract-syntax-tree angular-library typescript-compiler-api angular-schematics