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

Launching with command that auto configures serverPort? #936

Closed
santaclauze opened this issue Apr 15, 2018 · 8 comments · Fixed by #1460
Closed

Launching with command that auto configures serverPort? #936

santaclauze opened this issue Apr 15, 2018 · 8 comments · Fixed by #1460

Comments

@santaclauze
Copy link

Hi,

I am working with your library more and more and its awesome! So much that i am working on multiple modules that have styleguidist.

My issue is that:

Following the documentation it seems that the port used by styleguidist seems to be 6060 by default and that it can only be changed with serverPort , in the styleguide.config.js.

This is a pain as I do not want to change the config just for a temporary need.

Question / Request

Is it possible to launch the dev server by setting the port in the command?
ex:

$ npm run styleguide --port=6061
@sapegin
Copy link
Member

sapegin commented Apr 16, 2018

Sounds like a good feature, feel free to send a pull request ;-)

@santaclauze
Copy link
Author

Ill will try to make some time this weekend.

@philwolstenholme
Copy link

@santaclauze you could use https://github.com/indexzero/node-portfinder to set an open port automatically?

@gergely-nagy
Copy link
Contributor

gergely-nagy commented Apr 24, 2018

CRA uses detect-port. Maybe it's a better (or more secure) solution.
I can implement this feature if you don't have time for it.

@santaclauze
Copy link
Author

santaclauze commented Apr 24, 2018

@gergely-nagy, that would be great.

TBH, my family life make it hard to spend time on side projects and I am a dev in the making, so it takes even longer.

As for now, a quick and not elegant way was to replace the default serverPort settings to:

serverPort: { type: 'number', default: parseInt(process.argv[5] || '6060', 10), },

@kopax
Copy link
Collaborator

kopax commented May 29, 2018

I've published a quick fix in the schema for NODE_PORT. I've checked detect-port, it look simple but its' async which doesn't fit well with the current implementation.

See #995

@ruchernchong
Copy link

@gergely-nagy I tried with portfinder and am unable to increment the port if the previous port is used. There seems to be a Promise issue where the styleguidst server will finish launching the server before the Promise could finish. Would you like to help me on this?

@styleguidist-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 10.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

7 participants