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


TypeScript schematics.addModuleImportToRootModule函數代碼示例

本文整理匯總了TypeScript中@angular/cdk/schematics.addModuleImportToRootModule函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript addModuleImportToRootModule函數的具體用法?TypeScript addModuleImportToRootModule怎麽用?TypeScript addModuleImportToRootModule使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了addModuleImportToRootModule函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        return console.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
            `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
            `set up browser animations.`));
      }

      addModuleImportToRootModule(host, browserAnimationsModuleName,
          '@angular/platform-browser/animations', project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        '@angular/platform-browser/animations', project);
    }

    return host;
  };
開發者ID:Nodarii,項目名稱:material2,代碼行數:27,代碼來源:setup-project.ts

示例2: return

  return (tree: Tree, context: SchematicContext) => {
    const project = getProject(tree, options.project);
    const appModulePath = getAppModulePath(tree, getProjectMainFile(project));
    const browserAnimationsModuleName = 'BrowserAnimationsModule';
    const noopAnimationsModuleName = 'NoopAnimationsModule';
    const animationsPackage = '@angular/platform-browser/animations';

    if (options.animations) {
      // In case the project explicitly uses the NoopAnimationsModule, we should print a warning
      // message that makes the user aware of the fact that we won't automatically set up
      // animations. If we would add the BrowserAnimationsModule while the NoopAnimationsModule
      // is already configured, we would cause unexpected behavior and runtime exceptions.
      if (hasNgModuleImport(tree, appModulePath, noopAnimationsModuleName)) {
        return context.logger.warn(red(`Could not set up "${bold(browserAnimationsModuleName)}" ` +
          `because "${bold(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }

      addModuleImportToRootModule(tree, browserAnimationsModuleName, animationsPackage, project);
    } else if (!hasNgModuleImport(tree, appModulePath, browserAnimationsModuleName)) {
      // Do not add the NoopAnimationsModule module if the project already explicitly uses
      // the BrowserAnimationsModule.
      addModuleImportToRootModule(tree, noopAnimationsModuleName, animationsPackage, project);
    }
  }
開發者ID:kevinheader,項目名稱:nebular,代碼行數:25,代碼來源:index.ts

示例3: addModuleImportToApptModule

function addModuleImportToApptModule(host: Tree, moduleName: string, src: string,
                                     project: WorkspaceProject, appModulePath: string,
                                     options: Schema): void {
  if (hasNgModuleImport(host, appModulePath, moduleName)) {
    console.log(chalk.yellow(`Could not set up "${chalk.blue(moduleName)}" ` +
      `because "${chalk.blue(moduleName)}" is already imported. Please manually ` +
      `check "${chalk.blue(appModulePath)}" file.`));
    return;
  }
  addModuleImportToRootModule(host, moduleName, src, project);
}
開發者ID:SrgGs,項目名稱:ng-zorro-antd,代碼行數:11,代碼來源:add-required-modules.ts

示例4: return

  return (host: Tree) => {
    const workspace = getWorkspace(host);
    const project = getProjectFromWorkspace(workspace, options.project);
    const appModulePath = getAppModulePath(host, getProjectMainFile(project));

    if (options.animations) {
      if (hasNgModuleImport(host, appModulePath, noopAnimationsModuleName)) {
        console.log();
        return console.log(chalk.yellow(`Could not set up "${chalk.blue(browserAnimationsModuleName)}" ` +
          `because "${chalk.blue(noopAnimationsModuleName)}" is already imported. Please manually ` +
          `set up browser animations.`));
      }
      addModuleImportToRootModule(host, browserAnimationsModuleName,
        animationsModulePath, project);
    } else if (!hasNgModuleImport(host, appModulePath, browserAnimationsModuleName)) {
      addModuleImportToRootModule(host, noopAnimationsModuleName,
        animationsModulePath, project);
    }

    return host;
  };
開發者ID:SrgGs,項目名稱:ng-zorro-antd,代碼行數:21,代碼來源:add-animations-module.ts

示例5: it

    it('should not add NoopAnimationsModule if BrowserAnimationsModule is set up', () => {
      const workspace = getWorkspace(appTree);
      const project = getProjectFromWorkspace(workspace);

      // Simulate the case where a developer uses `ng-add` on an Angular CLI project which already
      // explicitly uses the `BrowserAnimationsModule`. It would be wrong to forcibly change
      // to noop animations.
      const fileContent = addModuleImportToRootModule(appTree, 'BrowserAnimationsModule',
          '@angular/platform-browser/animations', project);

      expect(fileContent).not.toContain('NoopAnimationsModule',
          'Expected the project app module to not import the "NoopAnimationsModule".');
    });
開發者ID:codef0rmer,項目名稱:material2,代碼行數:13,代碼來源:index.spec.ts

示例6: registerAppRoutingModule

function registerAppRoutingModule(tree: Tree, projectName: string) {
  const project = getProject(tree, projectName);
  addModuleImportToRootModule(tree, 'AppRoutingModule', './app-routing.module', project);
}
開發者ID:kevinheader,項目名稱:nebular,代碼行數:4,代碼來源:index.ts


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