Skip to content

Conversation

danielroe
Copy link
Member

nuxt/test-utils#1381 (comment)

this is a first stab at extracting logic for resolveConfigPath. I've left all behaviour untouched and still running in the same order, just pulled out a couple of routines which seemed relevant for resolving the source file - which means that there's probably scope for simplifying this

I've also switched to explicit exports for index.ts but of course that could be reverted

@danielroe danielroe requested a review from pi0 August 12, 2025 09:27
@danielroe danielroe self-assigned this Aug 12, 2025
@danielroe danielroe added the enhancement New feature or request label Aug 12, 2025
Resolve configuration file path:

```js
// Resolve the path to the configuration file without loading it
Copy link
Member

@pi0 pi0 Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If layers are used resolveConfigPath > resolveSources might also download layer which is not mentioned (also loading dotenv which is a side-effect) ~> #262 (comment)


const res = await resolveSources(".", options);

return res.configFile;
Copy link
Member

@pi0 pi0 Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we could make function more generic like resolePaths or resolveConfig returning an object either full res or a subset, cwd and configFile are particulary useful. If we also resolve rc config, it can be useful for automation scripts to know where to edit/append it. We also have information about layers alrady.


// Load dotenv
if (options.dotenv) {
await setupDotenv({
Copy link
Member

@pi0 pi0 Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? It might be helpful for cloning private layers i guess during resoluition but both are hidden side-effects specially if users pass same configuration they expect to pass to resolver and assume it will only try to resolve (not download or filling global env)

I am feeling we could make it opt-in with something like { sideEffect: true } or { loadLayers: true } or avoid side-effects from this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants