fsPromises.cp(src, dest[, options])
src<string> | <URL> 要复制的源路径。dest<string> | <URL> 要复制到的目标路径。options<Object>dereference<boolean> 取消引用符号链接。默认值:false。errorOnExist<boolean> 当force为false且目标存在时,抛出错误。默认值:false。filter<Function> 用于过滤复制的文件/目录的函数。返回true表示复制该项目,返回false表示忽略它。忽略目录时,其所有内容也将被跳过。还可以返回一个Promise,其解析结果为true或false。默认值:undefined。force<boolean> 覆盖已有的文件或目录。如果将此设置为 false 并且目标已存在,复制操作将忽略错误。使用errorOnExist选项可以更改此行为。默认值:true。mode<integer> 复制操作的修饰符。默认值:0。请参见fsPromises.copyFile()的mode标志。preserveTimestamps<boolean> 当true时间戳来自src时将被保留。默认值:false。recursive<boolean> 递归复制目录 默认值:falseverbatimSymlinks<boolean> 当true时,将跳过符号链接的路径解析。默认值:false
- 返回:<Promise> 成功后用
undefined完成。
异步地将整个目录结构从 src 复制到 dest,包括子目录和文件。
🌐 Asynchronously copies the entire directory structure from src to dest,
including subdirectories and files.
将目录复制到另一个目录时,不支持通配符,行为类似于 cp dir1/ dir2/。
🌐 When copying a directory to another directory, globs are not supported and
behavior is similar to cp dir1/ dir2/.