Skip to content

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.

2 participants