-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
π Bug report
Hi!
Command (mark with an x
)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
No.
Description
I'm trying to generate file from custom schema.
I've found incorrect behavior caused by @angular-devkit/schematics/src/rules/utils/is-binary.js
This function takes small chunks (24) of file and trying to detect is file binary or not.
So if file starts with string contains for example cyrrilic characters, isBinary will return incorrect result (true) because some symbols will be broken after cutting of 24 bits.
@schematics/angular/component/index.js
Call stack is rootFn => applyTemplates => applyContentTemplate => isBinary
I think this lib implements this function more correctly https://github.com/gjtorikian/isBinaryFile
π¬ Minimal Reproduction
I've builded https://github.com/angular/angular-cli/tree/master/packages/schematics/angular/component by tsc and then changed template of component schema (schematics/component/files/name@dasherize@if-flat/name@dasherize.component.ts.template), added these lines to top (comment block)
/**
* @overview Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―Π―
* @copyright Copyright (c) copyright, 2019
*/
and then run: ng g c foo
π₯ Exception or Error
Template file is not parsed because isBinary returned true, but it is not binary file
π Your Environment
windows 10
node 10
"@angular-devkit/core": "^7.3.4",
"@angular-devkit/schematics": "^7.3.4",
"@angular/cli": "^7.3.4",
"@types/jasmine": "^3.0.0",
"@types/node": "^8.0.31"
"jasmine": "^3.0.0",
"typescript": "3.2.4"
Anything else relevant?