本文整理汇总了TypeScript中@angular-devkit/schematics.Tree.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tree.get方法的具体用法?TypeScript Tree.get怎么用?TypeScript Tree.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics.Tree
的用法示例。
在下文中一共展示了Tree.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getUpdateFiles
function getUpdateFiles(localFiles: Tree) {
return [
{ path: "src/app/app.module.ts", file: localFiles.get("code/module")! },
{ path: "src/app/app.component.ts", file: localFiles.get("code/component")! },
{ path: "src/app/app.component.html", file: localFiles.get("code/component_template")! },
{ path: "src/styles.css", file: localFiles.get("assets/styles.css")! },
{ path: "src/index.html", file: localFiles.get("assets/index.html")! },
];
}
示例2: getFileContent
export function getFileContent(tree: Tree, path: string): string {
const fileEntry = tree.get(path);
if (!fileEntry) {
throw new Error(`The file (${path}) does not exist.`);
}
return fileEntry.content.toString();
}
示例3: envConfig
function envConfig(host: Tree, options: PluginOptions) {
const defEnvPath = `${options.sourceRoot}/environments/environment.ts`;
const defContent = host.get(defEnvPath).content;
if (!host.exists(defEnvPath)) return ;
// 1. update default env file
addValueToVariable(host, defEnvPath, 'environment', 'hmr: false');
// 2. update prod env file
addValueToVariable(host, `${options.sourceRoot}/environments/environment.prod.ts`, 'environment', 'hmr: false');
// 3. copy default env file to hmr file
const hmrEnvPath = `${options.sourceRoot}/environments/environment.hmr.ts`;
host.create(hmrEnvPath, defContent);
addValueToVariable(host, hmrEnvPath, 'environment', 'hmr: true');
}
示例4: getCreateFiles
function getCreateFiles(localFiles: Tree) {
return [
{ path: "src/app/app-routing.module.ts", file: localFiles.get("code/routing")! },
{ path: "src/config.json", file: localFiles.get("code/config")! },
{ path: "src/assets/alt.calendar.png", file: localFiles.get("assets/alt.calendar.png")! },
{ path: "src/assets/alt.list.png", file: localFiles.get("assets/alt.list.png")! },
{ path: "src/assets/alt.summary.png", file: localFiles.get("assets/alt.summary.png")! },
{ path: "src/assets/alt.table.png", file: localFiles.get("assets/alt.table.png")! },
{ path: "src/assets/calendar.png", file: localFiles.get("assets/calendar.png")! },
{ path: "src/assets/list.png", file: localFiles.get("assets/list.png")! },
{ path: "src/assets/summary.png", file: localFiles.get("assets/summary.png")! },
{ path: "src/assets/table.png", file: localFiles.get("assets/table.png")! },
{ path: "src/fonts/iconFont.eot", file: localFiles.get("fonts/iconFont.eot")! },
{ path: "src/fonts/iconFont.svg", file: localFiles.get("fonts/iconFont.svg")! },
{ path: "src/fonts/iconFont.ttf", file: localFiles.get("fonts/iconFont.ttf")! },
{ path: "src/fonts/iconFont.woff", file: localFiles.get("fonts/iconFont.woff")! },
{ path: "src/fonts/license.txt", file: localFiles.get("fonts/license.txt")! },
{ path: "src/theme.css", file: localFiles.get("assets/theme.css")! },
{ path: "src/theme.alt.css", file: localFiles.get("assets/theme.alt.css")! },
];
}