当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.getSystemPath函数代码示例

本文整理汇总了TypeScript中@angular-devkit/core.getSystemPath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getSystemPath函数的具体用法?TypeScript getSystemPath怎么用?TypeScript getSystemPath使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getSystemPath函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: switchMap

      switchMap(([[browserIndexOutputPath, indexContent], serverBundlePath]) => {
        const root = this.context.workspace.root;
        requireProjectModule(getSystemPath(root), 'zone.js/dist/zone-node');

        const renderModuleFactory = requireProjectModule(
          getSystemPath(root),
          '@angular/platform-server',
        ).renderModuleFactory;
        const AppServerModuleNgFactory = require(
          getSystemPath(serverBundlePath),
        ).AppServerModuleNgFactory;
        const indexHtml = virtualFs.fileBufferToString(indexContent);
        const outputPath = join(root, options.outputIndexPath || browserIndexOutputPath);

        // Render to HTML and overwrite the client index file.
        return from(
          renderModuleFactory(AppServerModuleNgFactory, {
            document: indexHtml,
            url: options.route,
          })
          .then((html: string) => {
            return this.context.host
              .write(outputPath, virtualFs.stringToFileBuffer(html))
              .toPromise();
          })
          .then(() => ({ success: true })),
        );
      }),
开发者ID:fmalcher,项目名称:angular-cli,代码行数:28,代码来源:index.ts

示例2: _updateWebdriver

  private _updateWebdriver(projectRoot: Path) {
    // The webdriver-manager update command can only be accessed via a deep import.
    const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';
    let webdriverUpdate: any; // tslint:disable-line:no-any

    try {
      // When using npm, webdriver is within protractor/node_modules.
      webdriverUpdate = requireProjectModule(getSystemPath(projectRoot),
        `protractor/node_modules/${webdriverDeepImport}`);
    } catch {
      try {
        // When using yarn, webdriver is found as a root module.
        webdriverUpdate = requireProjectModule(getSystemPath(projectRoot), webdriverDeepImport);
      } catch {
        throw new Error(tags.stripIndents`
          Cannot automatically find webdriver-manager to update.
          Update webdriver-manager manually and run 'ng e2e --no-webdriver-update' instead.
        `);
      }
    }

    // run `webdriver-manager update --standalone false --gecko false --quiet`
    // if you change this, update the command comment in prev line, and in `eject` task
    return from(webdriverUpdate.program.run({
      standalone: false,
      gecko: false,
      quiet: true,
    }));
  }
开发者ID:DevIntent,项目名称:angular-cli,代码行数:29,代码来源:index.ts

示例3: generateBrowserWebpackConfigFromWorkspace

export async function generateBrowserWebpackConfigFromWorkspace(
  options: BrowserBuilderSchema,
  context: BuilderContext,
  projectName: string,
  workspace: experimental.workspace.Workspace,
  host: virtualFs.Host<fs.Stats>,
  webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[],
  logger: logging.LoggerApi,
): Promise<webpack.Configuration[]> {
  // TODO: Use a better interface for workspace access.
  const projectRoot = resolve(workspace.root, normalize(workspace.getProject(projectName).root));
  const projectSourceRoot = workspace.getProject(projectName).sourceRoot;
  const sourceRoot = projectSourceRoot
    ? resolve(workspace.root, normalize(projectSourceRoot))
    : undefined;

  const normalizedOptions = normalizeBrowserSchema(
    host,
    workspace.root,
    projectRoot,
    sourceRoot,
    options,
  );

  return generateWebpackConfig(
    context,
    getSystemPath(workspace.root),
    getSystemPath(projectRoot),
    sourceRoot && getSystemPath(sourceRoot),
    normalizedOptions,
    webpackPartialGenerator,
    logger,
  );
}
开发者ID:angular,项目名称:angular-cli,代码行数:34,代码来源:webpack-browser-config.ts

示例4: prepareBrowserConfig

  // Mutates browserOptions
  prepareBrowserConfig(options: CordovaBuildBuilderSchema, browserOptions: BrowserBuilderSchema) {
    const cordovaBasePath = normalize(options.cordovaBasePath ? options.cordovaBasePath : '.');

    // We always need to output the build to `www` because it is a hard
    // requirement of Cordova.
    browserOptions.outputPath = join(cordovaBasePath, normalize('www'));

    if (options.cordovaAssets) {
      const platformWWWPath = join(cordovaBasePath, normalize(`platforms/${options.platform}/platform_www`));

      // Add Cordova www assets that were generated whenever platform(s) and
      // plugin(s) are added. This includes `cordova.js`,
      // `cordova_plugins.js`, and all plugin JS.
      browserOptions.assets.push({
        glob: '**/*',
        input: getSystemPath(platformWWWPath),
        output: './',
      });

      // Register `cordova.js` as a global script so it is included in
      // `index.html`.
      browserOptions.scripts.push({
        input: getSystemPath(join(platformWWWPath, normalize('cordova.js'))),
        bundleName: 'cordova',
        lazy: false,
      });
    }
  }
开发者ID:hayleykim424,项目名称:todoList,代码行数:29,代码来源:index.ts

示例5: buildWebpackConfig

  buildWebpackConfig(
    root: Path,
    projectRoot: Path,
    host: virtualFs.Host<fs.Stats>,
    options: NormalizedBrowserBuilderSchema,
  ) {
    // Ensure Build Optimizer is only used with AOT.
    if (options.buildOptimizer && !options.aot) {
      throw new Error('The `--build-optimizer` option cannot be used without `--aot`.');
    }

    let wco: WebpackConfigOptions<NormalizedBrowserBuilderSchema>;

    const tsConfigPath = getSystemPath(normalize(resolve(root, normalize(options.tsConfig))));
    const tsConfig = readTsconfig(tsConfigPath);

    const projectTs = requireProjectModule(getSystemPath(projectRoot), 'typescript') as typeof ts;

    const supportES2015 = tsConfig.options.target !== projectTs.ScriptTarget.ES3
      && tsConfig.options.target !== projectTs.ScriptTarget.ES5;

    wco = {
      root: getSystemPath(root),
      logger: this.context.logger,
      projectRoot: getSystemPath(projectRoot),
      buildOptions: options,
      tsConfig,
      tsConfigPath,
      supportES2015,
    };

    wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);

    const webpackConfigs: {}[] = [
      getCommonConfig(wco),
      getBrowserConfig(wco),
      getStylesConfig(wco),
      getStatsConfig(wco),
    ];

    if (wco.buildOptions.main || wco.buildOptions.polyfills) {
      const typescriptConfigPartial = wco.buildOptions.aot
        ? getAotConfig(wco, host)
        : getNonAotConfig(wco, host);
      webpackConfigs.push(typescriptConfigPartial);
    }

    const webpackConfig = webpackMerge(webpackConfigs);

    if (options.profile) {
      const smp = new SpeedMeasurePlugin({
        outputFormat: 'json',
        outputTarget: getSystemPath(join(root, 'speed-measure-plugin.json')),
      });

      return smp.wrap(webpackConfig);
    }

    return webpackConfig;
  }
开发者ID:cexbrayat,项目名称:angular-cli,代码行数:60,代码来源:index.ts

示例6: buildWebpackConfig

  buildWebpackConfig(
    root: Path,
    projectRoot: Path,
    options: NormalizedBrowserBuilderSchema,
  ) {
    let wco: WebpackConfigOptions;

    const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<fs.Stats>);

    const tsConfigPath = getSystemPath(normalize(resolve(root, normalize(options.tsConfig))));
    const tsConfig = readTsconfig(tsConfigPath);

    wco = {
      root: getSystemPath(root),
      logger: this.context.logger,
      projectRoot: getSystemPath(projectRoot),
      // TODO: use only this.options, it contains all flags and configs items already.
      buildOptions: options,
      tsConfig,
      tsConfigPath,
      supportES2015: false,
    };

    const webpackConfigs: {}[] = [
      // We don't need to write to disk.
      { plugins: [new InMemoryOutputPlugin()] },
      getCommonConfig(wco),
      getAotConfig(wco, host, true),
      getStylesConfig(wco),
      getStatsConfig(wco),
    ];

    return webpackMerge(webpackConfigs);
  }
开发者ID:DevIntent,项目名称:angular-cli,代码行数:34,代码来源:index.ts

示例7: concatMap

      concatMap(() => new Observable(obs => {
        const karma = requireProjectModule(getSystemPath(projectRoot), 'karma');
        const karmaConfig = getSystemPath(resolve(root, normalize(options.karmaConfig)));

        // TODO: adjust options to account for not passing them blindly to karma.
        // const karmaOptions: any = Object.assign({}, options);
        // tslint:disable-next-line:no-any
        const karmaOptions: any = {};

        if (options.watch !== undefined) {
          karmaOptions.singleRun = !options.watch;
        }

        // Convert browsers from a string to an array
        if (options.browsers) {
          karmaOptions.browsers = options.browsers.split(',');
        }

        if (options.reporters) {
          // Split along commas to make it more natural, and remove empty strings.
          karmaOptions.reporters = options.reporters
            .reduce<string[]>((acc, curr) => acc.concat(curr.split(/,/)), [])
            .filter(x => !!x);
        }

        const sourceRoot = builderConfig.sourceRoot && resolve(root, builderConfig.sourceRoot);

        karmaOptions.buildWebpack = {
          root: getSystemPath(root),
          projectRoot: getSystemPath(projectRoot),
          options: options as NormalizedKarmaBuilderSchema,
          webpackConfig: this._buildWebpackConfig(root, projectRoot, sourceRoot, host,
            options as NormalizedKarmaBuilderSchema),
          // Pass onto Karma to emit BuildEvents.
          successCb: () => obs.next({ success: true }),
          failureCb: () => obs.next({ success: false }),
        };

        // TODO: inside the configs, always use the project root and not the workspace root.
        // Until then we pretend the app root is relative (``) but the same as `projectRoot`.
        karmaOptions.buildWebpack.options.root = '';

        // Assign additional karmaConfig options to the local ngapp config
        karmaOptions.configFile = karmaConfig;

        // Complete the observable once the Karma server returns.
        const karmaServer = new karma.Server(karmaOptions, () => obs.complete());
        karmaServer.start();

        // Cleanup, signal Karma to exit.
        return () => {
          // Karma does not seem to have a way to exit the server gracefully.
          // See https://github.com/karma-runner/karma/issues/2867#issuecomment-369912167
          // TODO: make a PR for karma to add `karmaServer.close(code)`, that
          // calls `disconnectBrowsers(code);`
          // karmaServer.close();
        };
      })),
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:58,代码来源:index.ts

示例8: resolve

>((options, context) => {
  const configPath = resolve(normalize(context.workspaceRoot), normalize(options.webpackConfig));

  return from(import(getSystemPath(configPath))).pipe(
    switchMap((config: webpack.Configuration) => runWebpackDevServer(config, context)),
  );
});
开发者ID:angular,项目名称:angular-cli,代码行数:7,代码来源:index.ts

示例9: beforeEach

  beforeEach(() => {
    runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
    host = new TempScopedNodeJsSyncHost();
    tree = new UnitTestTree(new HostTree(host));

    writeFile('/tsconfig.json', JSON.stringify({
      compilerOptions: {
        lib: ['es2015'],
      }
    }));

    warnOutput = [];
    runner.logger.subscribe(logEntry => {
      if (logEntry.level === 'warn') {
        warnOutput.push(logEntry.message);
      }
    });

    previousWorkingDir = shx.pwd();
    tmpDirPath = getSystemPath(host.root);

    // Switch into the temporary directory path. This allows us to run
    // the schematic against our custom unit test tree.
    shx.cd(tmpDirPath);
  });
开发者ID:Cammisuli,项目名称:angular,代码行数:25,代码来源:template_var_assignment_migration_spec.ts


注:本文中的@angular-devkit/core.getSystemPath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。