-
Notifications
You must be signed in to change notification settings - Fork 57
Description
In #219, someone came to us with an issue: his project folder has been wiped out by SassDoc after running the regular command. This is no surprise.
There is a warning against this in the docs.
There is a warning against this in the README.
Needless to say running a command that compiles things on your root folder is definitely a bad idea, especially if you're not familiar with the tool you're using.
That being said, I think we could add some safeguards to avoid such a situation to happen again. At this point, we can think of a couple of different things.
Prompting
When running sassdoc
, prompt the user if the destination folder is not empty.
Are you sure you want to wipe out
<dest>
? [y/n]
Also add a --no-prompt
option (or whatever) to skip this step.
Folder testing
We could test whether the destination folder is parent of the source folder, in case we abort immediately. For instance:
sassdoc a/b/c a/b
The destination folder (
<dest>
) seems to be a parent folder from the source folder (<src>
). We don't want you to lose your data, so let's abort the whole thing, shall we?
Creating a folder
Instead of wiping the destination folder, we could create a sassdoc
folder (configurable) in the destination folder. This would prevent data from being erased. It would probably involve some extra logic that I don't really like.
Move to trash instead of deleting
One solution would be to use trash rather than rm -rf
.
What do you think? My opinion: either implement the first two simultaneously, or the fourth.