Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/angular_devkit/schematics/src/rules/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ export function applyContentTemplate<T>(options: T): FileOperator {
content: Buffer.from(templateImpl(decodedContent, {})(options)),
};
} catch (e) {
if (e instanceof TypeError) {
// The second part should not be needed. But Jest does not support instanceof correctly.
// See: https://github.com/jestjs/jest/issues/2549
if (
e instanceof TypeError ||
(e as NodeJS.ErrnoException).code === 'ERR_ENCODING_INVALID_ENCODED_DATA'
) {
return entry;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/angular_devkit/schematics/src/tree/host-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ export class HostTree implements Tree {
// With the `fatal` option enabled, invalid data will throw a TypeError
return decoder.decode(data);
} catch (e) {
if (e instanceof TypeError) {
// The second part should not be needed. But Jest does not support instanceof correctly.
// See: https://github.com/jestjs/jest/issues/2549
if (
e instanceof TypeError ||
(e as NodeJS.ErrnoException).code === 'ERR_ENCODING_INVALID_ENCODED_DATA'
) {
throw new Error(`Failed to decode "${path}" as UTF-8 text.`);
}
throw e;
Expand Down