From 5242c70a30968af5ea8e9c77b6d755b4886734f8 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 11 Jan 2022 01:53:23 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20provide=20config=20defaul?= =?UTF-8?q?ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ package.json | 1 + .../ngx-errors/src/lib/errors-configuration.ts | 2 +- projects/ngx-errors/src/lib/errors.module.ts | 15 +++++++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 79a9969..b2c2bbd 100644 --- a/README.md +++ b/README.md @@ -371,6 +371,8 @@ markDescendantsAsDirty(formControl); ### Basic Workflow +One time config: `git config --global push.followTags true` + 1. Develop 1. Write specs 1. Run `npm run test:lib` @@ -378,6 +380,7 @@ markDescendantsAsDirty(formControl); 1. Run `npm run release` 1. Run `npm run build:lib` 1. Go to the dist directory and run `npm publish` +1. Push changes `git push` ### Scripts diff --git a/package.json b/package.json index d1091fa..f37bbc9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "test:lib:coverage": "npm run test:lib -- --code-coverage", "postbuild:lib": "copyfiles README.md logo.png dist/ngx-errors", "release": "cd projects/ngx-errors && standard-version --infile ../../CHANGELOG.md", + "release:dry": "cd projects/ngx-errors && standard-version --infile ../../CHANGELOG.md --dry-run", "commitlint": "commitlint", "prepare": "husky install" }, diff --git a/projects/ngx-errors/src/lib/errors-configuration.ts b/projects/ngx-errors/src/lib/errors-configuration.ts index 61be702..beddb86 100644 --- a/projects/ngx-errors/src/lib/errors-configuration.ts +++ b/projects/ngx-errors/src/lib/errors-configuration.ts @@ -35,5 +35,5 @@ export interface IErrorsConfiguration { @Injectable() export class ErrorsConfiguration implements IErrorsConfiguration { showErrorsWhenInput = 'touched'; - showMaxErrors = undefined; + showMaxErrors: number | undefined = undefined; } diff --git a/projects/ngx-errors/src/lib/errors.module.ts b/projects/ngx-errors/src/lib/errors.module.ts index c4b7e3b..b504b8d 100644 --- a/projects/ngx-errors/src/lib/errors.module.ts +++ b/projects/ngx-errors/src/lib/errors.module.ts @@ -24,6 +24,17 @@ const declarationsAndExports = [ SetMatInputErrorStateMatcherDirective, ]; +const defaultConfig: ErrorsConfiguration = { + showErrorsWhenInput: 'touched', + showMaxErrors: undefined, +}; + +function mergeErrorsConfiguration( + config: IErrorsConfiguration +): ErrorsConfiguration { + return { ...defaultConfig, ...config }; +} + @NgModule({ imports: [ReactiveFormsModule], declarations: [...declarationsAndExports], @@ -37,14 +48,14 @@ const declarationsAndExports = [ }) export class NgxErrorsModule { static configure( - config?: IErrorsConfiguration + config: IErrorsConfiguration ): ModuleWithProviders { return { ngModule: NgxErrorsModule, providers: [ { provide: ErrorsConfiguration, - useValue: config, + useValue: mergeErrorsConfiguration(config), }, { provide: ErrorStateMatcher,