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

Adds --force option to create site in non-empty directory #580

Merged
merged 2 commits into from May 15, 2015

Conversation

Projects
None yet
2 participants
@TheLonelyGhost
Copy link
Contributor

commented May 13, 2015

Continuation of #549. Allows --force flag to override the site-already-exists safeguard

@@ -281,7 +282,7 @@ def run

# Check whether site exists
if File.exist?(path)

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne May 14, 2015

Member

Can you move the unless options[:force] next to the condition here?

if File.exist?(path) && !options[:force]

The options[:force] will otherwise be overlooked too easily, I feel.

@@ -281,7 +282,7 @@ def run

# Check whether site exists
if File.exist?(path)
raise Nanoc::Int::Errors::GenericTrivial, "A site at '#{path}' already exists."

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne May 14, 2015

Member

The error message isn’t as clear as it could be. Suggestion:

The site was not created, because #{path} already exists. If you really want to create a site in this directory, re-run this command with --force.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented May 14, 2015

Looks nice so far!

For an even better user experience, you could check whether path is a directory, and if it is, allow a site to be created with --force; it if is not a directory, don’t allow the site to be created (it would fail anyway).

@ddfreyne

This comment has been minimized.

Copy link
Member

commented May 14, 2015

You’ll have to rebase on top of master; the other PR conflicts with this one.

@TheLonelyGhost

This comment has been minimized.

Copy link
Contributor Author

commented May 14, 2015

It was originally based off of the other PR, but I figured it would be better kept as independent features in case one was accepted and the other rejected.

Rebased from master and moved the !options[:force] condition as per your suggestion while addressing merge conflicts.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented May 15, 2015

All good except for the message itself. “A site already exists” is incorrect. I propose the following:

The site was not created, because #{path} already exists. If you really want to create a site in this directory, re-run this command with --force.

What do you think?

@TheLonelyGhost

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2015

I feel like your suggestion is a bit wordy, but I can't think of an alternative that gives the same feel as the other messages in a more concise manner. Copypasta verbatim into the new error message.

@ddfreyne

This comment has been minimized.

Copy link
Member

commented May 15, 2015

Thanks!

ddfreyne added a commit that referenced this pull request May 15, 2015

Merge pull request #580 from TheLonelyGhost/feature/create-site-in-no…
…nempty-directory

Adds --force option to create site in non-empty directory

@ddfreyne ddfreyne merged commit 67df5ce into nanoc:master May 15, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

ddfreyne added a commit that referenced this pull request May 15, 2015

@TheLonelyGhost TheLonelyGhost deleted the TheLonelyGhost:feature/create-site-in-nonempty-directory branch May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.