當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript schematics.getProjectTargetOptions函數代碼示例

本文整理匯總了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')
  });
開發者ID:kevinheader,項目名稱:nebular,代碼行數:8,代碼來源:index.spec.ts

示例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;
}
開發者ID:codef0rmer,項目名稱:material2,代碼行數:9,代碼來源:project-index-html.ts

示例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');
    });
開發者ID:codef0rmer,項目名稱:material2,代碼行數:11,代碼來源:index.spec.ts

示例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);
}
開發者ID:kevinheader,項目名稱:nebular,代碼行數:15,代碼來源:index.ts

示例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));
    }
開發者ID:codef0rmer,項目名稱:material2,代碼行數:14,代碼來源:index.spec.ts

示例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));
}
開發者ID:SrgGs,項目名稱:ng-zorro-antd,代碼行數:42,代碼來源:theming.ts

示例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;
  };
開發者ID:SrgGs,項目名稱:ng-zorro-antd,代碼行數:24,代碼來源:add-icon-assets.ts

示例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.`);
 }
開發者ID:codef0rmer,項目名稱:material2,代碼行數:5,代碼來源:index.spec.ts


注:本文中的@angular/cdk/schematics.getProjectTargetOptions函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。