當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。