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

Add Checking and Force Flag for Directory in Serve Command #2265

Merged
merged 4 commits into from
Aug 17, 2023

Conversation

SquirrelHub
Copy link
Contributor

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:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

Copy link
Collaborator

@Keats Keats left a 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.
Copy link
Collaborator

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?

Copy link

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the wording that @Wabuo provided. Let me know if it looks alright @Keats.

@@ -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() {
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nah it's fine

@Keats Keats merged commit e81e139 into getzola:next Aug 17, 2023
peterprototypes pushed a commit to peterprototypes/zola that referenced this pull request Sep 12, 2023
)

* 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
technimad pushed a commit to technimad/zola that referenced this pull request Sep 30, 2023
)

* 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
Keats pushed a commit that referenced this pull request Dec 18, 2023
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants