本文整理汇总了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));
};
示例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;
}