本文整理匯總了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")! },
];
}