Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an error when config file is specified but not found #1514

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Y--
Copy link

@Y-- Y-- commented Oct 10, 2022

Hi!

A small contribution to explicitly raise an error if user specify a configuration file that cannot be resolved/found.

Please let me know:

  • if it makes sense :-)
  • if it is the right approach (I've tried to use the formatErrors utils but didn't seem to work in this case)
  • how I can test it (not sure where to put the test)

Thanks!!

@johnnyreilly
Copy link
Member

johnnyreilly commented Oct 13, 2022

Thanks for contributing! Is the logic for your check definitely correct?

if (loaderOptions.configFile !== undefined) { // should this be === undefined?
  configFileError = new Error(`Cannot find '${loaderOptions.configFile }' in folder '${path.dirname(loader.resourcePath)}'`);
}

@Y--
Copy link
Author

Y-- commented Oct 13, 2022

Thanks for contributing! Is the logic for your check definitely correct?

if (loaderOptions.configFile !== undefined) { // should this be === undefined?
  configFileError = new Error(`Cannot find '${loaderOptions.configFile }' in folder '${path.dirname(loader.resourcePath)}'`);
}

Well I want to throw an error if there is a file specified by the user (i.e. not undefined) but it is not found.

Basically I spent quite some time understanding why my config changes were not taken into account until I realized the file referenced in the loader did not exist, and the loader was instead creating a default configuration :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants