fix(atomic): make sure Stencil start on the good port #697
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
What's going on
Netlify even tho it does some framework detection, does not negotiate the 'targetPort' with the frameworks.
To understand why, we have to understand a bit how Netlify works, which is quite simple: As our CLI.
By that, I mean that the Netlify-CLI will do the same thing that we do: start other CLI (like
stencil-cli
in this instance).However, what it doesn't do is the 'port mapping' between the option given in input and the underlying CLIs.
Proposed fix
To alleviate that issue, I circumvent the Netlify-CLI by relying on the fact that it's good practice to 'carry the parent process.env around when spawning child processes.
This allows me to spawn
netlify-cli
with theSTENCIL_PORT
in its env, and to get it back when the stencil config is evaluated.We still pass
targetPort
so that whennetlify-cli
wait for the port of the framework to be open, it waits on the good one.Testing
Current FTs are enough, tho for some obscure reason, it was working on Linux. (like, the expected behaviour from our perspective was OK, the fact that it worked in Netlify is pretty nebulous tho).