Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 529721e

Browse files
author
Chau Tran
committed
feat: add "dev" property to globalSettings for withMapper
"dev" property will ensure errors aren't thrown in development mode. This is to help with NestJS HotModuleReload. In HMR mode, sometimes Profiles aren't cleaned up on hot reload so Duplicating Profile Exceptions will be thrown intermittenly fix #257
1 parent e7667ab commit 529721e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/automapper.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export class AutomapperModule implements OnModuleInit {
3030
const [name, globalSettings] = getWithMapperArgs(args);
3131
const mapper = new AutoMapper();
3232
if (globalSettings != null) {
33+
globalSettings.throwError =
34+
globalSettings.dev != null ? !globalSettings.dev : undefined;
3335
mapper.withGlobalSettings(globalSettings);
3436
}
3537

src/utils/getWithMapperArgs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AutoMapperGlobalSettings } from '@nartc/automapper';
22

33
export function getWithMapperArgs(
44
args: any[]
5-
): [string, AutoMapperGlobalSettings?] {
5+
): [string, (AutoMapperGlobalSettings & { dev?: boolean })?] {
66
if (!args.length) {
77
return [''];
88
}

0 commit comments

Comments
 (0)