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


TypeScript virtualFs.fileBufferToString方法代码示例

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


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

示例1: appendToFile

 appendToFile(path: string, str: string) {
   const content = virtualFs.fileBufferToString(this.scopedSync().read(normalize(path)));
   this.scopedSync().write(normalize(path),
     virtualFs.stringToFileBuffer(content.concat(str)));
 }
开发者ID:iwe7,项目名称:devkit,代码行数:5,代码来源:test-project-host.ts

示例2: tap

 tap(() => {
   expect(host.scopedSync().exists(extractionFile)).toBe(true);
   expect(virtualFs.fileBufferToString(host.scopedSync().read(extractionFile)))
     .toMatch(/i18n test/);
 }),
开发者ID:iwe7,项目名称:devkit,代码行数:5,代码来源:works_spec_large.ts

示例3: tap

 tap(() => {
   const fileName = join(outputPath, 'index.html');
   const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
   // tslint:disable-next-line:max-line-length
   expect(content).toBe(`<html><head><base href="/"><%= csrf_meta_tags %></head> <body><app-root></app-root><script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body></html>`);
 }),
开发者ID:DevIntent,项目名称:angular-cli,代码行数:6,代码来源:index_spec_large.ts

示例4: tap

 tap(() => Object.keys(jsMatches).forEach(fileName => {
   const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
   expect(content).toMatch(jsMatches[fileName]);
 })),
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:4,代码来源:styles_spec_large.ts

示例5: tap

 tap(() => {
   const fileName = join(outputPath, 'main.js');
   const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
   expect(content).toMatch(/Other content/);
 }),
开发者ID:iwe7,项目名称:devkit,代码行数:5,代码来源:i18n_spec_large.ts

示例6: tap

 tap(() => {
   const fileName = join(outputPath, 'runtime.js');
   const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
   expect(content).toContain('deployUrl/');
 }),
开发者ID:DevIntent,项目名称:angular-cli,代码行数:5,代码来源:deploy-url_spec_large.ts

示例7: tap

 tap(() => {
   const fileName = normalize('src/foo.ts');
   const content = virtualFs.fileBufferToString(host.scopedSync().read(fileName));
   expect(content).toContain(`const foo = '';`);
 }),
开发者ID:rexebin,项目名称:angular-cli,代码行数:5,代码来源:works_spec_large.ts

示例8: map

 map(data => virtualFs.fileBufferToString(data)),
开发者ID:angular,项目名称:angular-cli,代码行数:1,代码来源:write-index-html.ts

示例9: tap

 tap(() => {
   const fileName = join(outputPath, 'main.js');
   const content = virtualFs.fileBufferToString(host.scopedSync().read(fileName));
   // Bundle contents should be uglified, which includes variable mangling.
   expect(content).not.toContain('AppComponent');
 }),
开发者ID:iwe7,项目名称:devkit,代码行数:6,代码来源:optimization-level_spec_large.ts

示例10: augmentAppWithServiceWorker

export async function augmentAppWithServiceWorker(
  host: virtualFs.Host,
  projectRoot: Path,
  appRoot: Path,
  outputPath: Path,
  baseHref: string,
  ngswConfigPath?: string,
): Promise<void> {
  const distPath = normalize(outputPath);
  const systemProjectRoot = getSystemPath(projectRoot);

  // Find the service worker package
  const workerPath = normalize(
    require.resolve('@angular/service-worker/ngsw-worker.js', { paths: [systemProjectRoot] }),
  );
  const swConfigPath = require.resolve(
    '@angular/service-worker/config',
    { paths: [systemProjectRoot] },
  );

  // Determine the configuration file path
  let configPath;
  if (ngswConfigPath) {
    configPath = normalize(ngswConfigPath);
  } else {
    configPath = join(appRoot, 'ngsw-config.json');
  }

  // Ensure the configuration file exists
  const configExists = await host.exists(configPath).toPromise();
  if (!configExists) {
    throw new Error(tags.oneLine`
      Error: Expected to find an ngsw-config.json configuration
      file in the ${appRoot} folder. Either provide one or disable Service Worker
      in your angular.json configuration file.
    `);
  }

  // Read the configuration file
  const config = JSON.parse(virtualFs.fileBufferToString(await host.read(configPath).toPromise()));

  // Generate the manifest
  const GeneratorConstructor = require(swConfigPath).Generator as typeof Generator;
  const generator = new GeneratorConstructor(new CliFilesystem(host, outputPath), baseHref);
  const output = await generator.process(config);

  // Write the manifest
  const manifest = JSON.stringify(output, null, 2);
  await host.write(join(distPath, 'ngsw.json'), virtualFs.stringToFileBuffer(manifest)).toPromise();

  // Write the worker code
  // NOTE: This is inefficient (kernel -> userspace -> kernel).
  //       `fs.copyFile` would be a better option but breaks the host abstraction
  const workerCode = await host.read(workerPath).toPromise();
  await host.write(join(distPath, 'ngsw-worker.js'), workerCode).toPromise();

  // If present, write the safety worker code
  const safetyPath = join(dirname(workerPath), 'safety-worker.js');
  if (await host.exists(safetyPath).toPromise()) {
    const safetyCode = await host.read(safetyPath).toPromise();

    await host.write(join(distPath, 'worker-basic.min.js'), safetyCode).toPromise();
    await host.write(join(distPath, 'safety-worker.js'), safetyCode).toPromise();
  }
}
开发者ID:angular,项目名称:angular-cli,代码行数:65,代码来源:index.ts


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