you should check that `$sourceDirectory` is a directory first, to throw a better error.