spin icon indicating copy to clipboard operation
spin copied to clipboard

`files` manifest option should warn when `destination` does not appear to be a directory

Open rylev opened this issue 1 year ago • 3 comments

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.

rylev avatar May 14 '24 13:05 rylev

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" }

lann avatar May 14 '24 13:05 lann

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 / to destination
  • Don't warn on destination = "dest.txt/"

lann avatar May 14 '24 13:05 lann

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.

rylev avatar May 14 '24 15:05 rylev