File tree 2 files changed +12
-2
lines changed
packages/angular_devkit/schematics/src
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 {
62
62
content : Buffer . from ( templateImpl ( decodedContent , { } ) ( options ) ) ,
63
63
} ;
64
64
} 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
+ ) {
66
71
return entry ;
67
72
}
68
73
Original file line number Diff line number Diff line change @@ -304,7 +304,12 @@ export class HostTree implements Tree {
304
304
// With the `fatal` option enabled, invalid data will throw a TypeError
305
305
return decoder . decode ( data ) ;
306
306
} 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
+ ) {
308
313
throw new Error ( `Failed to decode "${ path } " as UTF-8 text.` ) ;
309
314
}
310
315
throw e ;
You can’t perform that action at this time.
0 commit comments