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

fix(docz-core): pass down host when running serve #1384

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/docz-core/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ export const serve = async (args: Arguments<any>) => {

if (config.port) {
cliArgs.push('--')
// Append gatsby option `port`to CLI args
// Append gatsby option `port` to CLI args
// https://www.gatsbyjs.org/docs/cheat-sheet/#cheat_sheet-text
cliArgs.push('--port')
cliArgs.push(String(config.port))
}

if (config.host) {
Copy link
Contributor

@alexandre-lelain alexandre-lelain Feb 9, 2020

Choose a reason for hiding this comment

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

I think we should do a more generic gatsby arguments handling, so users can use all of gatsby's cli arguments.

Something like:

for (const arg in config) {
  cliArgs.push('--')
  cliArgs.push(`--${arg}`)
  cliArgs.push(String(config[arg]))
}

This code will make sure to scale automatically when gatsby are adding new cli arguments.
Also, this would probably solve #1374.

What do you think @rakannimer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

config object now contains project config (menu, themeConfig...) other than gatsby's cli arguments.

image

If we want make it scale automatically, maybe add a gatsbyCliConfig to place these gatsby's arguments?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @alexandre-lelain, what you're saying makes sense to me, and I tried doing something like that a couple of commits ago but it resulted in some errors because of conflicts over variable names between docz config and gatsby. So while it looks redundant it might be better (for now) to explicitly pass down arguments.

Regarding #1374 it should be fixed in 2.3.0-alpha.11 but I forgot to update so thanks for the reminder !

// Append gatsby option `host` to CLI args
// https://www.gatsbyjs.org/docs/cheat-sheet/#cheat_sheet-text
cliArgs.push('--host')
cliArgs.push(String(config.host))
}

sh.cd(paths.docz)
spawnSync('npm', cliArgs)
}