本文整理汇总了TypeScript中@schematics/angular/utility/config.getWorkspacePath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getWorkspacePath函数的具体用法?TypeScript getWorkspacePath怎么用?TypeScript getWorkspacePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getWorkspacePath函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: return
return (host: Tree, context: SchematicContext) => {
const workspacePath = getWorkspacePath(host);
if (!workspacePath) {
return;
}
host.create(
`${workspacePath}.bak`, '// This is a backup file of the original angular.json. ' +
'This file is needed in case you want to revert to the workflow without Bazel.\n\n' +
host.read(workspacePath));
};
开发者ID:alxhub,项目名称:angular,代码行数:10,代码来源:index.ts
示例2: addResetCss
export function addResetCss(host: Tree): boolean {
const config = getWorkspace(host);
const project = config.projects[config.defaultProject] as WorkspaceProject<ProjectType.Application>;
let addPackage;
const styleExts = ['scss', 'sass', 'css', 'less', 'styl'];
const styleExt = styleExts.find(ext => host.exists(path.posix.join(project.sourceRoot, `styles.${ext}`)));
if (!styleExt) {
return false;
}
const stylesFile = path.posix.join(project.sourceRoot, `styles.${styleExt}`);
switch (styleExt) {
case 'sass':
case 'scss':
let content = host.read(stylesFile).toString();
if (content.indexOf(`~minireset.css/minireset`) === -1) {
content = scssImport + content;
host.overwrite(stylesFile, content);
addPackage = resetPackage;
}
break;
case 'css':
case 'less':
case 'styl':
if (!project.architect ||
!project.architect.build ||
project.projectType !== ProjectType.Application) {
return false;
}
if (project.architect.build.options.styles) {
project.architect.build.options.styles =
[cssImport, ...project.architect.build.options.styles];
} else {
project.architect.build.options.styles = [cssImport];
}
host.overwrite(getWorkspacePath(host), JSON.stringify(config, null, 2));
addPackage = resetPackage;
break;
default:
break;
}
if (addPackage) {
const targetFile = 'package.json';
if (host.exists(targetFile)) {
const pkgJson = JSON.parse(host.read(targetFile).toString());
pkgJson.dependencies = Object.assign({}, addPackage, pkgJson.dependencies);
host.overwrite(targetFile, JSON.stringify(pkgJson, null, 2) + '\n');
return true;
}
}
return false;
}
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:54,代码来源:add-normalize.ts
注:本文中的@schematics/angular/utility/config.getWorkspacePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论