Problem Description
The Deno task cp command behaves different that the system cp (GNU/POSIX) when used with a source that ends with a trailing /..
This breaks certain tasks that depend on that functionality to copy directory contents to a specific folder.
For example, consider a project that wants to copy the contents from a public/ folder into dist/:
Using system cp, the above command copies the contents of public directly into dist/, which is the expected behavior. However, when using the deno task runner with the cp command, the /. is normalized away and deno creates dist/public with the contents of public/.
cp behavior explained (AI-generated)
In a standard POSIX-compliant system (like GNU coreutils on Linux), the . isn't stripped away indiscriminately. The command cp -r public/. dist/ relies on file system resolution:
public/. tells cp that the explicit source is the directory . (the current directory reference inside public).
- It copies
. and deposits it into dist, effectively resolving to dist/. (which is just dist).
- As a result, the contents are merged directly into
dist without creating a public subfolder.
Alternative workarounds:
An alternative to using the cp -r public/. dist/ command would be just using cp -r public/* dist/, however that would ignore hidden files and folders, such as .well-known.
Problem Description
The Deno task
cpcommand behaves different that the systemcp(GNU/POSIX) when used with a source that ends with a trailing/..This breaks certain tasks that depend on that functionality to copy directory contents to a specific folder.
For example, consider a project that wants to copy the contents from a
public/folder intodist/:Using system
cp, the above command copies the contents ofpublicdirectly intodist/, which is the expected behavior. However, when using the deno task runner with the cp command, the/.is normalized away and deno createsdist/publicwith the contents ofpublic/.cp behavior explained (AI-generated)
In a standard POSIX-compliant system (like GNU coreutils on Linux), the
.isn't stripped away indiscriminately. The commandcp -r public/. dist/relies on file system resolution:public/.tellscpthat the explicit source is the directory.(the current directory reference insidepublic)..and deposits it intodist, effectively resolving todist/.(which is justdist).distwithout creating apublicsubfolder.Alternative workarounds:
An alternative to using the
cp -r public/. dist/command would be just usingcp -r public/* dist/, however that would ignore hidden files and folders, such as.well-known.