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


TypeScript core.resolve函數代碼示例

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


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

示例1: _deleteOutputDir

  private _deleteOutputDir(root: Path, outputPath: Path, host: virtualFs.Host) {
    const resolvedOutputPath = resolve(root, outputPath);
    if (resolvedOutputPath === root) {
      throw new Error('Output path MUST not be project root directory!');
    }

    return host.exists(resolvedOutputPath).pipe(
      concatMap(exists => exists
        // TODO: remove this concat once host ops emit an event.
        ? concat(host.delete(resolvedOutputPath), of(null)).pipe(last())
        // ? of(null)
        : of(null)),
    );
  }
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:14,代碼來源:index.ts

示例2: concatMap

 concatMap(buildEvent => {
   if (buildEvent.success && !options.watch && options.serviceWorker) {
     return from(augmentAppWithServiceWorker(
       host,
       root,
       projectRoot,
       resolve(root, normalize(options.outputPath)),
       options.baseHref || '/',
       options.ngswConfigPath,
     ).then(() => ({ success: true }), () => ({ success: false })));
   } else {
     return of(buildEvent);
   }
 }),
開發者ID:angular,項目名稱:angular-cli,代碼行數:14,代碼來源:index.ts

示例3: constructor

  constructor(
    private _compilerOptions: CompilerOptions,
    _basePath: string,
    private _JitMode: boolean,
    private _rootNames: string[],
    hostReplacementPaths: { [path: string]: string },
  ) {
    time('TypeChecker.constructor');
    const host = new virtualFs.AliasHost(new NodeJsSyncHost());

    // Add file replacements.
    for (const from in hostReplacementPaths) {
      const normalizedFrom = resolve(normalize(_basePath), normalize(from));
      const normalizedWith = resolve(
        normalize(_basePath),
        normalize(hostReplacementPaths[from]),
      );
      host.aliases.set(normalizedFrom, normalizedWith);
    }

    const compilerHost = new WebpackCompilerHost(
      _compilerOptions,
      _basePath,
      host,
      true,
    );
    // We don't set a async resource loader on the compiler host because we only support
    // html templates, which are the only ones that can throw errors, and those can be loaded
    // synchronously.
    // If we need to also report errors on styles then we'll need to ask the main thread
    // for these resources.
    this._compilerHost = createCompilerHost({
      options: this._compilerOptions,
      tsHost: compilerHost,
    }) as CompilerHost & WebpackCompilerHost;
    timeEnd('TypeChecker.constructor');
  }
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:37,代碼來源:type_checker.ts

示例4: 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(',');
        }

        karmaOptions.buildWebpack = {
          root: getSystemPath(root),
          projectRoot: getSystemPath(projectRoot),
          options: options as NormalizedKarmaBuilderSchema,
          webpackConfig: this._buildWebpackConfig(root, projectRoot, 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:rexebin,項目名稱:angular-cli,代碼行數:49,代碼來源:index.ts

示例5: augmentAppWithServiceWorker

        const callback: webpack.compiler.CompilerCallback = (err, stats) => {
          if (err) {
            return obs.error(err);
          }

          const json = stats.toJson(statsConfig);
          if (options.verbose) {
            this.context.logger.info(stats.toString(statsConfig));
          } else {
            this.context.logger.info(statsToString(json, statsConfig));
          }

          if (stats.hasWarnings()) {
            this.context.logger.warn(statsWarningsToString(json, statsConfig));
          }
          if (stats.hasErrors()) {
            this.context.logger.error(statsErrorsToString(json, statsConfig));
          }

          if (options.watch) {
            obs.next({ success: !stats.hasErrors() });

            // Never complete on watch mode.
            return;
          } else {
            if (builderConfig.options.serviceWorker) {
              augmentAppWithServiceWorker(
                this.context.host,
                root,
                projectRoot,
                resolve(root, normalize(options.outputPath)),
                options.baseHref || '/',
                options.ngswConfigPath,
              ).then(
                () => {
                  obs.next({ success: !stats.hasErrors() });
                  obs.complete();
                },
                (err: Error) => {
                  // We error out here because we're not in watch mode anyway (see above).
                  obs.error(err);
                },
              );
            } else {
              obs.next({ success: !stats.hasErrors() });
              obs.complete();
            }
          }
        };
開發者ID:iwe7,項目名稱:devkit,代碼行數:49,代碼來源:index.ts

示例6: run

  run(builderConfig: BuilderConfiguration<ProtractorBuilderOptions>): Observable<BuildEvent> {

    const options = builderConfig.options;
    const root = this.context.workspace.root;
    const projectRoot = resolve(root, builderConfig.root);
    // const projectSystemRoot = getSystemPath(projectRoot);

    // TODO: verify using of(null) to kickstart things is a pattern.
    return of(null).pipe(
      concatMap(() => options.devServerTarget ? this._startDevServer(options) : of(null)),
      concatMap(() => options.webdriverUpdate ? this._updateWebdriver(projectRoot) : of(null)),
      concatMap(() => this._runProtractor(root, options)),
      take(1),
    );
  }
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:15,代碼來源:index.ts

示例7: buildWebpackConfig

  buildWebpackConfig(
    root: Path,
    projectRoot: Path,
    sourceRoot: Path | undefined,
    host: virtualFs.Host<fs.Stats>,
    options: NormalizedKarmaBuilderSchema,
  ) {
    let wco: WebpackConfigOptions;

    const tsConfigPath = getSystemPath(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;

    const compatOptions: typeof wco['buildOptions'] = {
      ...options as {} as typeof wco['buildOptions'],
      // Some asset logic inside getCommonConfig needs outputPath to be set.
      outputPath: '',
    };

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

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

    const webpackConfigs: {}[] = [
      getCommonConfig(wco),
      getStylesConfig(wco),
      getNonAotTestConfig(wco, host),
      getTestConfig(wco),
    ];

    return webpackMerge(webpackConfigs);
  }
開發者ID:cexbrayat,項目名稱:angular-cli,代碼行數:46,代碼來源:index.ts

示例8: run

  run(builderConfig: BuilderConfiguration<Partial<Schema>>): Observable<BuildEvent> {
    const projectRoot = getSystemPath(resolve(this.context.workspace.root, builderConfig.root));
    const targetLabel = builderConfig.options.targetLabel;

    const executable = builderConfig.options.watch ? 'ibazel' : 'bazel';

    if (!checkInstallation(executable, projectRoot)) {
      throw new Error(
          `Could not run ${executable}. Please make sure that the ` +
          `"${executable}" command is available in the $PATH.`);
    }

    // TODO: Support passing flags.
    return runBazel(
               projectRoot, executable, builderConfig.options.bazelCommand !, targetLabel !,
               [] /* flags */)
        .pipe(map(() => ({success: true})), catchError(() => of ({success: false})), );
  }
開發者ID:cyrilletuzi,項目名稱:angular,代碼行數:18,代碼來源:index.ts

示例9: Observable

 return new Observable(obs => {
   augmentAppWithServiceWorker(
     this.context.host,
     root,
     projectRoot,
     resolve(root, normalize(options.outputPath)),
     options.baseHref || '/',
     options.ngswConfigPath,
   ).then(
     () => {
       obs.next({ success: true });
       obs.complete();
     },
     (err: Error) => {
       obs.error(err);
     },
   );
 });
開發者ID:cexbrayat,項目名稱:angular-cli,代碼行數:18,代碼來源:index.ts

示例10: run

  run(builderConfig: BuilderConfiguration<BuildWebpackServerSchema>): Observable<BuildEvent> {
    const options = builderConfig.options;
    const root = this.context.workspace.root;
    const projectRoot = resolve(root, builderConfig.root);
    const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<Stats>);
    const webpackBuilder = new WebpackBuilder({ ...this.context, host });

    // TODO: verify using of(null) to kickstart things is a pattern.
    return of(null).pipe(
      concatMap(() => options.deleteOutputPath
        ? this._deleteOutputDir(root, normalize(options.outputPath), this.context.host)
        : of(null)),
      concatMap(() => addFileReplacements(root, host, options.fileReplacements)),
      concatMap(() => {
        const webpackConfig = this.buildWebpackConfig(root, projectRoot, host, options);

        return webpackBuilder.runWebpack(webpackConfig, getBrowserLoggingCb(options.verbose));
      }),
    );
  }
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:20,代碼來源:index.ts


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