-
Notifications
You must be signed in to change notification settings - Fork 978
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
Add Checking and Force Flag for Directory in Serve Command #2265
Add Checking and Force Flag for Directory in Serve Command #2265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor tweaks if you want, nothing big
@@ -81,6 +81,8 @@ web browser. | |||
|
|||
Before starting, Zola will delete the output directory (by default `public` in project root) to start from a clean slate. | |||
|
|||
If you are specifying the directory however using the `output-dir` flag, Zola will not use the specified directory if it already exists unless the --force flag is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be just my English but wouldn't If you are however specifying the director using the
output-dir flag
be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Randomly came across this while checking out Zola ... I'm throwing
If you are specifying the directory but are also using the `output-dir` flag, Zola will not use the specified directory if it already exists unless the --force flag is used.
in the ring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -268,6 +269,12 @@ fn create_new_site( | |||
site.enable_serve_mode(); | |||
site.set_base_url(base_url); | |||
if let Some(output_dir) = output_dir { | |||
if !force && output_dir.exists() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would swap the 2 conditions just because it would be clearer imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern honestly was taken straight from the build command's pattern of ifs.
Do you still think it's worth changing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah it's fine
* Introduce option to force directory when running the serve command * Update documentation about the force flag on the serve command * Resolve cargo fmt issue * Reword new serve flag documentation
Attempts to address #2251 by mimicking behavior of
build
command's checking of existing folders from the--output-dir
flag, and also allows the use of a new--force
flag to override said directory for serving the files.IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one: