PhoenicisOrg / scripts

Phoenicis scripts
GNU Lesser General Public License v3.0
64 stars 49 forks source link

Split "fileExists" into "fileExists" and "directoryExists" #1124

Open madoar opened 5 years ago

madoar commented 5 years ago

Currently we provide a single method fileExists which checks whether a given file path exists. This method can be used to check both if a file and if a directory exists. In case the method is used to check whether a directory exists it looks out of place, for example:

if (!fileExists(fontDirectory)) {
   mkdir(fontDirectory);
}

To improve this we should split the current fileExists method into a fileExists and a directoryExists method, which should be disjunct (exclude each other). More specific if a directory path is passed to fileExists and if a file is passed to directoryExists the methods should throw an error.

For more details see also https://github.com/PhoenicisOrg/scripts/pull/1116#discussion_r322902989