File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
packages/angular_devkit/schematics/src Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,12 @@ export function applyContentTemplate<T>(options: T): FileOperator {
6262 content : Buffer . from ( templateImpl ( decodedContent , { } ) ( options ) ) ,
6363 } ;
6464 } catch ( e ) {
65- if ( e instanceof TypeError ) {
65+ // The second part should not be needed. But Jest does not support instanceof correctly.
66+ // See: https://github.com/jestjs/jest/issues/2549
67+ if (
68+ e instanceof TypeError ||
69+ ( e as NodeJS . ErrnoException ) . code === 'ERR_ENCODING_INVALID_ENCODED_DATA'
70+ ) {
6671 return entry ;
6772 }
6873
Original file line number Diff line number Diff line change @@ -304,7 +304,12 @@ export class HostTree implements Tree {
304304 // With the `fatal` option enabled, invalid data will throw a TypeError
305305 return decoder . decode ( data ) ;
306306 } catch ( e ) {
307- if ( e instanceof TypeError ) {
307+ // The second part should not be needed. But Jest does not support instanceof correctly.
308+ // See: https://github.com/jestjs/jest/issues/2549
309+ if (
310+ e instanceof TypeError ||
311+ ( e as NodeJS . ErrnoException ) . code === 'ERR_ENCODING_INVALID_ENCODED_DATA'
312+ ) {
308313 throw new Error ( `Failed to decode "${ path } " as UTF-8 text.` ) ;
309314 }
310315 throw e ;
You can’t perform that action at this time.
0 commit comments