本文整理汇总了TypeScript中@angular/cdk/schematics.getProjectTargetOptions函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getProjectTargetOptions函数的具体用法?TypeScript getProjectTargetOptions怎么用?TypeScript getProjectTargetOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getProjectTargetOptions函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should register inline theme if no theme already registered', () => {
const tree = runSetupSchematic({ customization: false });
const workspace = getWorkspace(tree);
const project = getProjectFromWorkspace(workspace);
const styles = getProjectTargetOptions(project, 'build').styles;
expect(styles).toContain('./node_modules/@nebular/theme/styles/prebuilt/default.css')
});
示例2: getIndexHtmlPath
export function getIndexHtmlPath(project: WorkspaceProject): string {
const buildOptions = getProjectTargetOptions(project, 'build');
if (!buildOptions.index) {
throw new SchematicsException('No project "index.html" file could be found.');
}
return buildOptions.index;
}
示例3: it
it('should not add a theme file multiple times', async () => {
writeStyleFileToWorkspace(appTree, defaultPrebuiltThemePath);
const tree = await runner.runSchematicAsync('ng-add-setup-project', {}, appTree).toPromise();
const workspace = getWorkspace(tree);
const project = getProjectFromWorkspace(workspace);
const styles = getProjectTargetOptions(project, 'build').styles;
expect(styles).toEqual(['projects/material/src/styles.css', defaultPrebuiltThemePath],
'Expected the "styles.css" file and default prebuilt theme to be the only styles');
});
示例4: addStyleToTarget
/**
* Adds a style entry to the given project target.
* */
function addStyleToTarget(project: WorkspaceProject, targetName: string, tree: Tree,
stylesPath: string, workspace: WorkspaceSchema) {
const targetOptions = getProjectTargetOptions(project, targetName);
if (!targetOptions.styles) {
targetOptions.styles = [stylesPath];
} else if (noNebularThemeIncluded(targetOptions, stylesPath)) {
targetOptions.styles.unshift(stylesPath);
}
writeJSON(tree, 'angular.json', workspace);
}
示例5: writeStyleFileToWorkspace
/** Writes a specific style file to the workspace in the given tree */
function writeStyleFileToWorkspace(tree: Tree, stylePath: string) {
const workspace = getWorkspace(tree);
const project = getProjectFromWorkspace(workspace);
const buildOptions = getProjectTargetOptions(project, 'build');
if (!buildOptions.styles) {
buildOptions.styles = [stylePath];
} else {
buildOptions.styles.push(stylePath);
}
tree.overwrite('/angular.json', JSON.stringify(workspace, null, 2));
}
示例6: addThemeStyleToTarget
/** Adds a theming style entry to the given project target options. */
function addThemeStyleToTarget(project: WorkspaceProject, targetName: 'test' | 'build', host: Tree,
assetPath: string, workspace: WorkspaceSchema): void {
// Do not update the builder options in case the target does not use the default CLI builder.
if (!validateDefaultTargetBuilder(project, targetName)) {
return;
}
const targetOptions = getProjectTargetOptions(project, targetName);
if (!targetOptions.styles) {
targetOptions.styles = [ assetPath ];
} else {
const existingStyles = targetOptions.styles.map(s => typeof s === 'string' ? s : s.input);
for (const [ index, stylePath ] of existingStyles.entries()) {
// If the given asset is already specified in the styles, we don't need to do anything.
if (stylePath === assetPath) {
return;
}
// In case a prebuilt theme is already set up, we can safely replace the theme with the new
// theme file. If a custom theme is set up, we are not able to safely replace the custom
// theme because these files can contain custom styles, while prebuilt themes are
// always packaged and considered replaceable.
if (stylePath.includes(defaultCustomThemeFilename)) {
console.log();
console.warn(chalk.yellow(`Could not style file to the CLI project configuration ` +
`because there is already a custom theme file referenced.`));
console.warn(chalk.yellow(`Please manually add the following style file to your configuration:`));
console.warn(chalk.cyan(`${chalk.bold(assetPath)}`));
return;
} else if (stylePath.includes(compiledThemePathSegment)) {
targetOptions.styles.splice(index, 1);
}
}
targetOptions.styles.unshift(assetPath);
}
host.overwrite('angular.json', JSON.stringify(workspace, null, 2));
}
示例7: return
return (host: Tree) => {
const workspace = getWorkspace(host);
const project = getProjectFromWorkspace(workspace, options.project);
const targetOptions = getProjectTargetOptions(project, 'build');
if (!targetOptions.assets) {
targetOptions.assets = [ { ...iconAssetObject } ];
} else {
const assets = targetOptions.assets as Array<string | object>;
const assetsString = JSON.stringify(assets);
if (!assetsString.includes(iconPathSegment)) {
assets.push({ ...iconAssetObject });
} else {
console.log();
console.log(chalk.yellow(`Could not add the icon assets to the CLI project assets ` +
`because there is already a icon assets file referenced.`));
console.log(chalk.yellow(`Please manually add the following config to your assets:`));
console.log(chalk.cyan(JSON.stringify(iconAssetObject, null, 2)));
return host;
}
}
host.overwrite('angular.json', JSON.stringify(workspace, null, 2));
return host;
};
示例8: expectProjectStyleFile
/** Expects the given file to be in the styles of the specified workspace project. */
function expectProjectStyleFile(project: WorkspaceProject, filePath: string) {
expect(getProjectTargetOptions(project, 'build').styles).toContain(filePath,
`Expected "${filePath}" to be added to the project styles in the workspace.`);
}