Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Allows creation of site in current directory #549
Could you elaborate on the issue you had where nanoc didn’t properly detect a site already existed? It should error out if the given destination directory already exists (even if it’s a file instead of a directory).
I’m uncertain whether this enhancement is useful, for two reasons:
You're right that defaulting to the current directory is less clear than the current documentation.
Given the above, I have 3 options:
With this pull request, all three scenarios would react as expected.
Being able to create a site into an empty directory (which fits your use case) seems useful. I’d change the
if File.exist?(path) && (!File.directory?(path) || Dir.entries(path) != ['.', '..']) # … end
I prefer to have the second argument be mandatory. Having a default argument is confusing.
Also, I’m afraid I’ve done some work on the create-site command and your changes are not longer mergeable. Could you rebase onto
Rebasing now. I'm removing the sections where it defaults to the current directory since you make valid points.
While working on the section about empty directory, I ran into an issue. Checking if the directory is empty may not be right response either since my use case assumes a fresh git branch. With git, even a fresh branch will not be empty since it must contain the
Would a prompt requiring confirmation be better if the directory is not empty?
If you mean an interactive prompt, then I’d say “no”, simply because there are no interactive parts in the nanoc CLI elsewhere.
Printing a warning and aborting when the given directory exists and is not empty makes sense. I’d say that message could say this:
Also, a new