Nikaple / nest-typed-config

Intuitive, type-safe configuration module for Nest framework ✨
MIT License
207 stars 25 forks source link

fix: do not attempt substitution if the loader failed #497

Closed jacquesg closed 12 months ago

jacquesg commented 12 months ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

What is the current behavior?

When substitution of environment variables in enabled in the fileLoader, an exception is generated as the check for whether or not the config actually loaded is missing:

TypeError: Cannot read properties of null (reading 'config')                                                                                                                                              
    at Object.transform (/home/jacquesg/dev/projects/asterias/deianira/node_modules/nest-typed-config/lib/loader/file-loader.ts:120:41)

Issue Number: N/A

What is the new behavior?

The validity is checked, and the correct error is now generated:

/home/jacquesg/dev/projects/asterias/deianira/node_modules/nest-typed-config/lib/typed-config.module.ts:79
    return load();
           ^
Error: Failed to find configuration file.
    at /home/jacquesg/dev/projects/asterias/deianira/node_modules/nest-typed-config/lib/loader/file-loader.ts:135:5

Does this PR introduce a breaking change?

Other information

github-actions[bot] commented 12 months ago

:tada: This PR is included in version 2.9.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

jacquesg commented 12 months ago

Wow, that was fast, thank you :)