spin
spin copied to clipboard
`files` manifest option should warn when `destination` does not appear to be a directory
Given the following manifest configuration:
files = [{ source = "static/foo.txt", destination = "bar.txt" }]
I would expect at least a warning as I believe destination must always be a directory. If source is a file, that file will be located inside the destination directory, and if source is a directory, all the files will be available at destination. I imagine we can't always error because paths that look like file names are still legal directory names (i.e., "foo.txt" can be a directory name), but we can at least issue a warning as this is more than likely a bug.
Edit: it seems that destinations as files are allowed, but this will break in very weird ways if source is a directory and not a file.
I'm not sure I see an obvious heuristic for this warning. Dots in directory names aren't very common but they occur often enough (e.g. the somewhat common config.d/* pattern) that I wouldn't want to introduce noise for what I would expect to be a relatively rare mistake: { source = "dir", destination = "why-would-this-be-a-file.txt" }
A somewhat-fiddly option here would be to:
- Allow a trailing slash in directory
destinations (if we don't already; I didn't check) - Warn on e.g.
{ source = "dir", destination = "dest.txt" }, with a note that the warning can be suppressed by adding/todestination - Don't warn on
destination = "dest.txt/"
This might just be a documentation issue. The docs aren't very clear about the possible permutations here, and that might have been enough to avoid the confusion I ran into.