Skip to content

font file extensions should be added to binaryExts in generateFiles #5213

@erikagiroux

Description

@erikagiroux

Current Behavior

Binary files like font files can sometimes contain characters like <% and this can result in an error when running generateFiles because ejs tries to find a closing tag that does not exist. In my case, it happens with a .woff2 file but it could happen with other file types as well.

The error looks like this:

Error: Could not find matching close tag for "<%".

Expected Behavior

Binary files should not be rendered with ejs. I know image files have already been excluded. The same could be done with font files. The most common extensions for web fonts could be added to the list of binaryExts:

  • ttf
  • otf
  • woff
  • woff2
  • eot

It would be even better if we could identify binary formats automatically but since image extensions were added manually, it would make sense to include fonts too in order to cover the most common web assets.

Steps to Reproduce

  1. Create a new generator
  2. Create a new folder containing a font file that has <% somewhere it its content
  3. Use generateFiles to copy the folder containing the font file when running the generator
  4. The command will fail with this error
Error: Could not find matching close tag for "<%".

Environment

This is a blank workspace created by npx create-nx-plugin. It contains only a generator.

  Node : 14.15.2
  OS   : linux x64
  npm  : 6.14.9

  nx : Not Found
  @nrwl/angular : Not Found
  @nrwl/cli : 11.6.1
  @nrwl/cypress : Not Found
  @nrwl/devkit : 11.6.1
  @nrwl/eslint-plugin-nx : 11.6.1
  @nrwl/express : Not Found
  @nrwl/jest : 11.6.1
  @nrwl/linter : 11.6.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : 11.6.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.6.1
  @nrwl/web : Not Found
  @nrwl/workspace : 11.6.1
  @nrwl/storybook : Not Found
  @nrwl/gatsby : Not Found
  typescript : 4.0.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions