private async _buildInMemoryFileDictionary()

in src/app/shared/stack-blitz/stack-blitz-writer.ts [108:135]


  private async _buildInMemoryFileDictionary(
      data: ExampleData, exampleId: string, isTest: boolean): Promise<FileDictionary> {
    const result: FileDictionary = {};
    const tasks: Promise<unknown>[] = [];
    const liveExample = EXAMPLE_COMPONENTS[exampleId];
    const exampleBaseContentPath =
      `${DOCS_CONTENT_PATH}/${liveExample.module.importSpecifier}/${exampleId}/`;

    for (const relativeFilePath of TEMPLATE_FILES) {
      tasks.push(this._loadFile(TEMPLATE_PATH + relativeFilePath)
        // Replace example placeholders in the template files.
        .then(content => this._replaceExamplePlaceholders(data, relativeFilePath, content, isTest))
        .then(content => result[relativeFilePath] = content));
    }

    for (const relativeFilePath of data.exampleFiles) {
      tasks.push(this._loadFile(exampleBaseContentPath + relativeFilePath)
        // Insert a copyright footer for all example files inserted into the project.
        .then(content => this._appendCopyright(relativeFilePath, content))
        .then(content => result[`src/app/${relativeFilePath}`] = content));
    }

    // Wait for the file dictionary to be populated. All file requests are
    // triggered concurrently to speed up the example StackBlitz generation.
    await Promise.all(tasks);

    return result;
  }